Gary
Gary

Reputation: 453

Trouble with jquery load on Google Chrome

I'm creating a demo that must be in html code only (no server side code such as PHP, etc). I'd like to use jquery and the .load function to call in some content dynamically. This is working fine in Firefox, but for some reason the page I want to get is not loading in Chrome (v 5.0).

The code I am using is very simple:

  $("div#contentarea").load("ajax/page.html");

and yet the contents of page.html do not load. I've tried putting standard HTML header tags in (<html>, <head>, <body>, etc) and also leaving them out (leaving them out usually works best) of the page.html file.

Because this works in Firefox, I am not seeing any error messages in Firebug.

Thanks in advance for any help!

Upvotes: 2

Views: 2278

Answers (4)

user2888181
user2888181

Reputation: 11

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.

Upvotes: 0

Albin
Albin

Reputation: 11

As Strager said, adding --allow-file-access-from-files to a Chrome shortcut solves this issue. I also found that by also adding --relauncher, you don't need to close your open chrome windows for this to work. this was a huge thing for me!

Glad I got it to work. Thanks guys!

Upvotes: 1

strager
strager

Reputation: 90022

This is the result of a bug fix in Chrome.

Run Chrome with the --allow-file-access-from-files option to fix this problem. Or, move your code on a Web server (instead of using file://).

Upvotes: 3

dockeryZ
dockeryZ

Reputation: 3981

Here's a good read. http://groups.google.com/group/jquery-en/msg/14925da1b4540acd?pli=1

May or may not help

Upvotes: 0

Related Questions