JQuery development and Chrome local files access

If you have been developing a web page using JQuery and trying access some local json file.

$.getJSON("your path to the local file",
        function(data){
          //some code
        });

You might have found out that trying to run your code con Chrome it fails and with little detail on why it isn't working. You may have thought that there is a problem with your code or even with the validation of the json data which is an option also. But before going all crazy reviewing all of the code. Check this:

Chrome for security reasons doesn't allow local files to access other local files by default. So if you want your code to work there is a simple fix. Start your Chrome browser using the following parameter:

--allow-file-access-from-files

and thats it your code should be working now and you should be able to work on your json data.

If you are using firefox then you should take a look at this link:
http://kb.mozillazine.org/Links_to_local_pages_do_not_work

On Internet Explorer I didn't find any problems trying to run the code so I assume it is enabled by default (is this a security risk?)

Comments

Popular posts from this blog

RabbitMQ first reactions

Start-up