我的客户有一个 WordPress 博客,我们正在将 RSS 提要发送到主页以显示过去的 3 篇文章...我正在使用 jquery,一切都运行完美。
我们将 IP 更改为专用 IP,突然间它停止工作了。我的XHR是0!我假设它认为这是一个跨域问题。
对于临时修复,我编写了一个 php 代理来加载文件,并且我正在使用 ajax -- (有效 - 注意:文件位于 wp 目录中,因此这不是目录范围内的问题)
谢谢!
//编辑(代码)
$.ajax({
url: '/blog/?feed=rss2',
success: function() {
alert('worked');
},
error: function(x){
alert(x.status);
}
});
$.ajax({
url: '/blog/proxy.php',
success: function() {
alert('worked');
},
error: function(x){
alert(x.status);
}
});
注意:proxy.php 只是打开“/blog/?feed=rss2”
我在 proxy.php 上成功,但得到 jqXHR.status = 0
最佳答案
尝试检查其中一些以获取更多详细信息。一定要使用 Firebug 或 Chrome 的 XHR 调试器 (F12)
For backward compatibility with XMLHttpRequest, a jqXHR object will expose the following properties and methods:
- readyState
- status
- statusText
- responseXML and/or responseText when the underlying request responded with xml and/or text, respectively
- setRequestHeader(name, value)
- getAllResponseHeaders()
- getResponseHeader()
- abort()
关于jquery - 同一域上的ajax跨域错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8306439/