【问题标题】:AJAX call results in status 0AJAX 调用导致状态 0
【发布时间】:2013-02-23 16:28:59
【问题描述】:
$.ajax({
    url:"myurl",
    async:true,
    success:function (data) {
         //....
    },
    complete:function (x, st) {
         //....
    },
    error:function (x, st, e) {
         alert(JSON.stringify(x));
    }
});

这是 ajax 调用。 如果我尝试在浏览器中访问“myurl”,它工作正常。 但是 Ajax 调用总是会导致错误。 如果我对 xhr 进行字符串化,它看起来像这样:

{
  "readyState": 0,
  "responseText": "",
  "status": 0,
  "statusText": "error"
}

【问题讨论】:

标签: javascript ajax http jquery


【解决方案1】:

问题可能出在这些 URL 重定向的地方——只有 1 个留在域内:

http://www.barnesandnoble.com/s?keyword=9780735619678&store=ebook #->
http://www.barnesandnoble.com/...

http://www.barnesandnoble.com/s?keyword=9780201485677&store=ebook #->
http://search.barnesandnoble.com/...

您需要在权限中包含search.barnesandnoble.com

"permissions": [
    "http://www.barnesandnoble.com/",
    "http://search.barnesandnoble.com/"
]

【讨论】:

  • 非常感谢,我没有注意到他们重定向到不同的域。
猜你喜欢
  • 2016-08-08
  • 2010-12-13
  • 1970-01-01
  • 2013-01-29
  • 1970-01-01
  • 1970-01-01
  • 2018-03-25
  • 2017-10-09
  • 1970-01-01
相关资源
最近更新 更多