Prestashop模块中的Ajax

时间:2015-04-10 07:54:12

标签: php jquery ajax prestashop-1.6

我在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;
    })
})

我有空警。

我检查了很多方法来解决我的问题,但没有人帮助我。

有人可以解释我的错误吗?

1 个答案:

答案 0 :(得分:0)

try this:

public function GetData(){
    if(Tools::getValue('method')) die(json_encode('ciao'));;
        echo "method not found!";
}