谁能指出为什么我的 JavaScript 函数落入错误函数而不是成功函数? Ubuntu 上的 Firefox
$(document).ready(function() {
console.log( "Start" );
$.ajax({ type: "GET", dataType: "html", url: "http://slashdot.org",
error: function(request, status) {
console.log("Error");
},
success: function(data) {
console.log("Sucess");
}
});
console.log( "End" );
});
最佳答案
因为same-origin security restrictions ,您不能向当前网页域以外的域发出 ajax 调用。
可能的解决方法取决于您的实际问题:
在您的域上构建服务器代理,该代理将为您从其他站点获取网页,以便您可以将请求发送到您自己的域。
使用 iframe 显示来自另一个域的内容。
关于javascript - Firefox 上的 jQuery URL 获取错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12868658/