getJson() is not working in chrome

getJson j-query method is not working in chrome while it is working in all other browsers

following is my code



     /// my code goes here

}; };

error i am getting in chrome is

my JSON file is with in the same folder


You are trying to read a file from your client machine with file: protocol, which is not safe. It doesn't work in Chrome, because Chrome cares about the security issues more than other browsers. it seems to me you are trying to create a sample ajax.

What you can do is simply disable the web security in chrome, if it is just a sample testing, open your Chrome in comand line with this parameter: --disable-web-security

and if it is not a sample test, you have to put your file on a server that you have access to it and use http ajax call instead of file ajax call.

If you had this problem on the web, there would be two options to fix it, using JSONP or enabling CORS. but in file protocol I can offer you to fake a JSONP call like this:

-first it you json file is like this:

   name : "abc" //...
   name : "efg" //...

change it to (wrap it in a function call):

   name : "abc" //...
   name : "efg" //...

then do this instead of jQuery ajax call:

window.callback = function(jsonObj){
var script = document.createElement('script');
//since this is a fake jsonp call you don't need to add ?callback=callback to url
script.src = 'aptitude14.json';

Need Your Help

Catch Abort signal on hudson in shell script?


How can we trap the abort signal of the job on hudson so that i can do some post steps in case of abort (I am running a job on hudson which has shell script running in background)?