Filip
Filip

Reputation: 81

Loading a div from a different domain

I'm hosting a page on an sharepoint site, and need to pull content from multiple other pages. The content I need is on a different domain in a div, so I cannot use an iFrame. I've tried the following code with JQuery attempting to load the stcakoverflow container div from the landing page, but this doesn't seem to work. I'm assuming this is due to different origin policy:

<script>
    $(document).ready(function() {
       $('#LoadMe').load("http://www.stackoverflow.com#container");
    });
 </script>

Is there a way to do this through Jquery, or is there an alternate solution?

Upvotes: 0

Views: 494

Answers (3)

You can also get the content of the page that you need and parse it with regexp or as above was said Nate B, Write some type of code for example Rss Feed, Pass content with json, create some web service and etc

Upvotes: 0

Abdullah Jibaly
Abdullah Jibaly

Reputation: 54830

If you can encode the other domain's data in JSON, you can do cross-domain requests using JSONP requests. This of course requires that you are able to change or request a different type of encoding from the other domains so if that's not under your control this approach is not possible.

Upvotes: 1

Nate B
Nate B

Reputation: 6344

No, you can't just load up another page (or a piece of it) like that with Javascript. You would need to do it on the backend via PHP, .NET, or some other server-side scripting language, then pass the results to your page.

Upvotes: 0

Related Questions