Sixfoot Studio
Sixfoot Studio

Reputation: 3011

Load external content using AJAX

Is it possible to load an external site's content using jQuery's Ajax rather than an iFrame?

This is what I am trying to achieve, but it would seem there might be some cross domain issues with this?

$('#result').load('http://www.google.com');

In flash you can put a cross-domain policy file in the root of the site allow certain sites to access the content of swf files or other files. Is this something that could be done using AJAX?

Thanks, James

Upvotes: 0

Views: 897

Answers (2)

quantumSoup
quantumSoup

Reputation: 28172

It is possible, in part. You'll need to have your server act as a proxy:

$('#result').load('fetch.php?s=http://www.google.com');
// or something like that

As for having the client load a page cross-domain, it won't (shouldn't) be possible.

Upvotes: 2

Quentin
Quentin

Reputation: 944295

Is it possible to load an external site's content using jQuery's Ajax rather than an iFrame?

The Same Origin Policy usually prevents it. You can work around it using JSON-P to transport that data.

In flash you can put a cross-domain policy file in the root of the site allow certain sites to access the content of swf files or other files. Is this something that could be done using AJAX?

Not cross-browser, the standard is too new (and unfinished)

Upvotes: 1

Related Questions