Reputation: 11
I'm using jQTouch which is an implementation of jQuery with some extra stuff for mobile devices. I have a div with id=testinner. When I use this code, it works fine from a local file:
$("#testinner").load("test.html");
But if I test with a remote file, nothing loads
$("#testinner").load("http://www.google.com");
Anyone have any idea what I'm doing wrong?
Upvotes: 1
Views: 2848
Reputation: 27313
You're trying to make an ajax call which is forbidden by the same origin policy.
If you want to fetch some data from a different domain, you have to use JSON-P
$.getJSON('http://www.google.com', function(data) {
});
Upvotes: 2
Reputation: 66191
Cross-domain restrictions exist, even for jQtouch applications. What you are doing is breaking that rule by trying to request a page that is outside of the current domain name.
If you want to access external data, it will have to support JSON-P(JSON with a callback) or it will need to exist on the same server your code sits on.
Upvotes: 4