0

Possible Duplicate:
“Origin null is not allowed by Access-Control-Allow-Origin” in Chrome. Why?

I am fairly new to jquery and javascript in general. I am building an offline site but would like to use ajax for the online site.

However, I am finding that jquery load() is giving me an error when trying to attempt offline:

Here is my code:

$('.container').load('somecontent.html', function(){
  everythingelse();
});

var everythingelse = function() { blah blah }

And here is my error:

XMLHttpRequest cannot load file:///Users/me/Desktop/somecontent.html. Origin null is not allowed by Access-Control-Allow-Origin. 

I assume that this is because I am not behind any server.

My questions are:

  • What does the error mean?
  • Is there a way to use jquery load() when offline? alternative method? or something that acts similar?

I want to load the contents of an html file into another html file locally! and without a server.

[EDIT] I just found out that this works flawlessly in Firefox, but chrome has the issue as pointed out by imm below.

Community
  • 1
  • 1
Xacto01
  • 83
  • 5
  • he [jQuery documentation is clear on what the `.load()` method](http://api.jquery.com/load/) is for: load data from the server and place the returned HTML into the matched element. That said what I'm unsure of after reading your question is if you want the same code to work in an offline and online state. Or if we are talking about two completely different apps. If it's the former there are ways to have jQuery work from cached data. Please clear up exactly how you want your app to behave and I'll see if I can't be of assistance. – ahsteele Feb 28 '12 at 03:24
  • Yes, I'm gunning for a localized version where .load() would work offline, and simply porting the static html online would not require any changes to my code. the 2 html files would essentially be part of the same APP and would be in the same directory. I also added a note: (I found out that load works just fine in Firefox, but doesn't in Chrome.) – Xacto01 Feb 28 '12 at 03:28
  • 1
    if you develop in Firefox you can load from local files without changing any settings – charlietfl Feb 28 '12 at 03:33

0 Answers0