开发者

jQuery $.getJSON: "Failed to load resource: cancelled"

开发者 https://www.devze.com 2023-02-05 10:59 出处:网络
I\'m having problem loading a json resource from a local rails app with jQuery 1.4.4 The json is valid (based on jsonlint.com) and I can download it properly if I\'m requesting it from other sources.

I'm having problem loading a json resource from a local rails app with jQuery 1.4.4

The json is valid (based on jsonlint.com) and I can download it properly if I'm requesting it from other sources.

In webkit (Safari), I got this error:

Failed to load resource: cancelled

Response Header on Firebug:

Content-Type application/json; charset=utf-8
Set-Cookie geoloc=toulouse; path=/;
Connection close
Server thin 1.2.7 codename No Hup

jQuery code to load json:

$.getJSON("http://127.0.0.1/search_agenda开发者_StackOverflow",
  {'edition': edition,
  'categories': categories},
  function(data){
    console.log(data);
  }
});


Your getJSON seems correct to me.

I had the same error. And it actually is due to jquery mobile. I haven't gotten to the bottom of it, but basically I get this error even if I just include the jquery mobile libraries in a blank html page.

I suspect that the jquery.js and jquery_mobile.js are incompatible versions. I will check back when I find out the real reason.


Ensure that you're loading the page from http://127.0.0.1/ in your browser too. Anyway, it's always a better option to use relative paths.


try putting a relative path. Ajax calls are forbidden between different domains, so your browser may think that your app is on the localhost domain and the request is in a different one (127.0.0.1).

If this is the case, you can try something like :

$.getJSON("http://" + location.host + "/search_agenda",
  {'edition': edition,
  'categories': categories},
  function(data){
    console.log(data);
  }
);
0

精彩评论

暂无评论...
验证码 换一张
取 消