Reputation:
How to use jquery to loading external url inside divtag using load() method?
My tag like this
<div id="preview">
</div>
and i want load www.stackoverflow.com inside this tag.
Upvotes: 0
Views: 136
Reputation: 1039170
You can't do this using jQuery.load because it performs an AJAX request which due to browser security restrictions is not allowed on cross domain (except if your site is hosted on stackoverflow.com).
As a workaround you could create a server side script (hosted on your site) which serves as a bridge between stackoverflow.com and your site and perform the AJAX request on this script.
$('#preview').load('http://yourdomain.com/somescript');
Upvotes: 4
Reputation: 40072
$('#preview').load(your url goes here)
As noted, you can't do this cross-domain. You could load content from your own domain this way, but not from stackoverflow.com (since it's doubtful you'll be hosted at that domain...)
Upvotes: 0