Robert Spangler

UI/UX designer & front-end developer

Navigation

JQuery .load() Doesn’t Work in Chrome

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.

4 Responses to “JQuery .load() Doesn’t Work in Chrome”

  1. Willy

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

    Reply
  2. Frank

    Hello Rob. Thank you very much for the good advice in your blog! I was really wondering about Chrome’s local load-behaviour and could not believe, that I had to do some extra stuff for the latest browser ;-) So it really is not necessary. Thankyou for posting!

    Greeting from Switzerland
    Frank

    Reply
  3. chasnz

    As a workaround I found the .get function works well. I don’t need to run Chrome with any special flags.

    $.get(_url, pars, function(data) {
    $( ‘#ajaxReplaceMe’ ).html( data );
    });

    Where ajaxReplaceMe is the id of the (say) div element where you want the content to load.

    Reply

Leave a Reply

  • (will not be published)

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

About Robert

I work with clients ranging from local small businesses and non-profits to large Fortune 500 companies.

If you think I'm the right guy for your project, please feel free to give me a shout.

I am a full-time freelance website designer and front-end developer from Baltimore, Maryland, currently living in Nairobi, Kenya.

I design and code for user experience on the web with special attention on mobile devices. I come from a background in eCommerce and lead generation, which I'm very good at. I spend most of my time personalizing and creating customized WordPress themes for clients. Other than designing websites I spend time with family, study, occasionally tweet, and rarely +.