gpt4 book ai didi

javascript - jQuery 中的 Ajax 调用问题

转载 作者:行者123 更新时间:2023-12-01 02:54:39 24 4
gpt4 key购买 nike

我正在使用以下代码从服务器接收一些数据。它总是返回 200 ok,并根据我的请求提供所需的数据。但它不会触发成功或错误事件。如果有人能帮助我,我将不胜感激。

$('body').on('click','a.btn_details',function(e){
e.preventDefault();
var _id = $(this).attr('id');
var _data = {'action': 'product_details','product_id':_id};
$.ajax({
method: 'POST',
url: '../common/products.php',
dataType: 'json',
data: _data,
succes: function (resp) {
alert(resp.name);
return false;
},
error: function(resp){
alert("xd,vj,dfjbj");
}
});
$('#prd_list_cont').hide();
$('#prd_det_cont').show();
});

提前致谢,

艾莎扎法尔

最佳答案

您的 Ajax 请求中有错误。您需要将 succes 替换为 success :

success: function (resp) {
alert(resp.name);
return false;
},

祝你好运

关于javascript - jQuery 中的 Ajax 调用问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46786822/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com