Cui Pengfei 崔鹏飞
Cui Pengfei 崔鹏飞

Reputation: 8305

AJAX call results in status 0

$.ajax({
    url:"myurl",
    async:true,
    success:function (data) {
         //....
    },
    complete:function (x, st) {
         //....
    },
    error:function (x, st, e) {
         alert(JSON.stringify(x));
    }
});

This is the ajax call. If I try to access the "myurl" in browser, it works fine. But the Ajax call always results in error. If I stringify the xhr, it looks like this:

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

Upvotes: 0

Views: 803

Answers (1)

Jonathan Lonowski
Jonathan Lonowski

Reputation: 123423

The issue is likely where those URLs are redirecting -- only 1 stays in-domain:

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/...

You'll need to include search.barnesandnoble.com in your permissions:

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

Upvotes: 1

Related Questions