我在prestahop中遇到ajax响应问题。
我用方法
编写了模块cheaperproduct.php
public function GetData(){
if(Tools::getValue('method')) echo "asdasd";
echo "string";
}
并在main.js
中jQuery(document).ready(function(){
$('#cheaper form').submit(function(){
var url = $("#cheaper .url").val();
var email = $("#cheaper .email").val();
$.ajax({
url: baseDir+'modules/cheaperproduct/cheaperproduct.php',
method:"post",
data:'method=GetData',
success: function(data){
alert(data);
}
})
return false;
})
})
我有空警。
我检查了很多方法来解决我的问题,但没有人帮助我。
有人可以解释我的错误吗?
答案 0 :(得分:0)
try this:
public function GetData(){
if(Tools::getValue('method')) die(json_encode('ciao'));;
echo "method not found!";
}