-4

What i want to do:

Extract html of other domain.

What i have tried:

$.get("http://website1.com", function(data) {
alert("Data Loaded: " + data);
});

(not working)

(for example) im the owner of tow websites:

website1.com
website2.com

now i want to get the html of website1.com and then show the html in website2.com by using jquery or any other way (website2.com Support Client-side languages Only ,website1.com Support Php).

HOW Can I Do It(im the owner of website1 and website2)?

  • 5
    implement CORS, or JSONP. if you went to the console you would see *"Access Denied due to Same-Origin Policy"*, and if you googled that, you would have gotten this same information. – Kevin B May 08 '13 at 14:14
  • im the owner of website1 and website2, so i can give access to specific domain? – mnio112233 May 08 '13 at 14:16
  • I guess you should take a look at this: http://stackoverflow.com/questions/3837717/get-html-of-external-url-in-jquery – arekstasiewicz May 08 '13 at 14:16
  • @mnio112233 Yes, using CORS. Note that IE7 doesn't support CORS and IE8/9 only partially supports it (will need to extend jQuery) – Kevin B May 08 '13 at 14:16

2 Answers2

0

Consider using an iframe to display a page on your page.

klewis
  • 7,459
  • 15
  • 58
  • 102
0

Add following header to your website1 php will allow $.get() in website2 to get website1 content.

header('Access-Control-Allow-Origin: http://website2.com');
Xelio
  • 66
  • 4