我的代码是:
var test = "it isn't working";
var response = $.ajax({
type: 'GET',
url: 'jquerydemo.php', //This is in the same site as the page calling this request, so it's not a same-domain error.
success: function(){
test = "it's working";
},
error: function(){
alert("Error detected");
}
}).responseText;
alert(test);
我测试了状态代码,结果是 200,错误功能从未关闭,但成功功能也没有。正如我在评论中所说,这不是同源策略错误。它只是一直说“它不工作”。这是怎么回事?
最佳答案
试试这个:
error: function(jqXHR, textStatus, errorThrown) {
console.log(JSON.stringify(jqXHR));
console.log("AJAX error: " + textStatus + ' : ' + errorThrown);
}
关于javascript - 如何调试 jQuery Ajax 请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6991306/