Design Blog

JQuery .load() Doesn’t Work in Chrome

March 25, 2011 | Filed Under Code Snippets, JavaScript by

If you do any front-end development locally (and test in Google Chrome) you may have run into a problem using the .load() function or other AJAX requests. The functions are just unable to return any data, It boils down to a permissions issue with Chrome pointing to local files.

You can resolve this by uploading your files to a live production server, but that is a pain, especially if you’re still in development.

There’s a very simple solution:

1. Close Chrome completely
2. Launch Chrome from Terminal with the “–allow-file-access-from-files” argument

open /Applications/Google\ Chrome.app --args --allow-file-access-from-files

This will allow that session of Chrome to access local files. Note: Once you close and reopen the application you’ll no longer have access to local files again.

2 Responses to JQuery .load() Doesn’t Work in Chrome

  1. Willy says:

    Hey Rob, thanks for sharing the solution! I had just spent about 15 minutes being really confused as to why .load wasn’t working.

  2. Rotu says:

    Hello Rob. Thanks a lot for your help. I found this link through stackoverflow [1] and finally could solve this problem. I’m just learning jQuery and was going crazy with this. Also English is not my native language and is very hard to find certain answers.

    Again: Thanks!!

    [1]: http://stackoverflow.com/questions/5616618/jquery-and-browser-compatibility

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>