我的代码是:
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);
Run Code Online (Sandbox Code Playgroud)
我测试了状态代码,它出现了200并且错误函数永远不会消失,但成功函数也没有.就像我在评论中所说的那样,它不是同源政策错误.它只是停留说"它不起作用".这里发生了什么?