While testing a Javascript app under Chrome today, I learned something interesting. If the HTML/JS file you're viewing in Chrome is located on the local drive (ie. you're accessing it via file:///...) then you're not normally able to use AJAX to request other files on the local hard drive. I tried doing the following in jQuery:
$.getJSON("local/file/on/hard-drive", function (response){
// blah blah blah
});
Every single time, the
response variable would come out as null. I wasn't sure what happened, but after a quick Google search I learned that in order to make Chrome play nice with local files, you need to disable web security:
google-chrome filename.html --disable-web-security
After this it seems to work just fine! Now to fix the other bugs...
No comments:
Post a Comment