JQuery $ .getJSON: "Failed to load resource: canceled"

I have a problem loading json resource from local rails application using jQuery 1.4.4

json is valid (based on jsonlint.com) and I can download it correctly if I request it from other sources.

In webkit (Safari), I got this error:

Failed to load resource: cancelled 

Firebug response header:

 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 download json:

 $.getJSON("http://127.0.0.1/search_agenda", {'edition': edition, 'categories': categories}, function(data){ console.log(data); } }); 
+4
source share
4 answers

Your getJSON seems right to me.

I had the same error. And actually it is connected with jQuery mobile. I have not reached the end, but basically I get this error, even if I just turn on jQuery mobile libraries on an empty HTML page.

I suspect jquery.js and jquery_mobile.js are incompatible versions. I'll be back when I find out the true reason.

+1
source

Make sure you load the page from http://127.0.0.1/ into your browser. In any case, it is always better to use relative paths.

0
source

try removing single quotes from keys and adding them to json structure values. Edit: ok forget quotation marks in values, since they are probably variables.

0
source

try setting the relative path. Ajax calls are forbidden between different domains, so your browser might think that your application is in the localhost domain and the request is in another ( 127.0.0.1 ).

If so, you can try something like:

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

Source: https://habr.com/ru/post/1335972/


All Articles