views:

1450

answers:

2

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?

+2  A: 

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.

Doug Neiner
+2  A: 

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) {
 });
RageZ
Its a hard call isn't it? if you edit the OP's post to make it readable, you risk someone else answering the question first :)
Doug Neiner
@dcneiner: yep especially if the OP really poorly formated the question but sometimes SO is more about quality of answer then being the first!
RageZ
This URL might be better, since it supports JSON-P: `quotesondesign.com/api/3.0/api-3.0.json?callback=my_function`
Doug Neiner
@dcneiner: thanks! updated!
RageZ
@Abie: thanks for the corrections
RageZ