Jquery Magento+;ajax404错误
我正在编写一个模块来在Magento中执行一个简单的Ajax调用,但它在控制台中给出了404错误 config.xml文件为Jquery Magento+;ajax404错误,jquery,magento,Jquery,Magento,我正在编写一个模块来在Magento中执行一个简单的Ajax调用,但它在控制台中给出了404错误 config.xml文件为 <?xml version="1.0"?> <config> <modules> <Custom_Personalize> <version>0.1.0</version> </Custom_Personalize> </modules>
<?xml version="1.0"?>
<config>
<modules>
<Custom_Personalize>
<version>0.1.0</version>
</Custom_Personalize>
</modules>
<frontend>
<routers>
<personalize>
<use>standard</use>
<args>
<module>Custom_Personalize</module>
<frontName>personalize</frontName>
</args>
</personalize>
</routers>
<layout>
<updates>
<personalize>
<file>personalize.xml</file>
</personalize>
</updates>
</layout>
</frontend>
<admin>
<routers>
<personalize>
<use>admin</use>
<args>
<module>Custom_Personalize</module>
<frontName>admin_personalize</frontName>
</args>
</personalize>
</routers>
</admin>
<layout>
<updates>
<personalize>
<file>personalize.xml</file>
</personalize>
</updates>
</layout>
</adminhtml>
</config>
jQuery代码是
<script type="text/javascript">
jQuery(document).on('change', '.shapes', function() {
console.log("hii");
jQuery.ajax({
url: "<?php echo $this->getUrl() ?>"+'personalize/ajax/index',
type: "POST",
data: "size=123456",
success: function(data) {
console.log(data);
return false;
}
});
});
</script>
jQuery(document).on('change','.shapes',function()){
控制台日志(“hii”);
jQuery.ajax({
url:“+”个性化/ajax/index“,
类型:“POST”,
数据:“大小=123456”,
成功:功能(数据){
控制台日志(数据);
返回false;
}
});
});
请说明我遗漏了什么
感谢您提到Blockpersonalize/personalize,您需要在Block/personalize.php中定义该块,并且需要将该块定义到config.xml中 如果扩展中未定义任何块,则可以使用核心/模板,如下所示:
<?xml version="1.0"?>
<layout>
<personalize_ajax_index>
<block type="core/template" name="root" output="toHtml" template="personalize/ajax.phtml" />
</personalize_ajax_index>
</layout>
test
<script type="text/javascript">
jQuery(document).on('change', '.shapes', function() {
console.log("hii");
jQuery.ajax({
url: "<?php echo $this->getUrl() ?>"+'personalize/ajax/index',
type: "POST",
data: "size=123456",
success: function(data) {
console.log(data);
return false;
}
});
});
</script>
<?xml version="1.0"?>
<layout>
<personalize_ajax_index>
<block type="core/template" name="root" output="toHtml" template="personalize/ajax.phtml" />
</personalize_ajax_index>
</layout>