0

See this:

$("#anyselector").click(function(){
 $("html").load("http://www.aurl.com html"); 
});

EDIT:

DAMN IT! SORRY! I DIDN'T MENTIONED ITS DONE ON SAME DOMAIN!!!!

Sounds foolish. But I hope you got me what I'm trying to achieve. Is that right?

mehulmpt
  • 15,861
  • 12
  • 48
  • 88
  • 2
    _Sounds foolish._..... bit seems cross domain html access. You can't do that. – Jai Apr 30 '14 at 13:12
  • possible duplicate of [Loading cross domain html page with jQuery AJAX](http://stackoverflow.com/questions/15005500/loading-cross-domain-html-page-with-jquery-ajax) – Cerbrus Apr 30 '14 at 13:39
  • If you found any of the answers helpful, do you mind marking an accepted answer? Cheers! – Mohamad Dec 22 '14 at 18:15

3 Answers3

0

As per jQuery's documentation:

Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, port, or protocol.

This means you can only load sections hosted on your own server, into the page.

However, This SO answer has some cross-domain workarounds.

Community
  • 1
  • 1
Cerbrus
  • 70,800
  • 18
  • 132
  • 147
0

There are some libraries that do this, such as PJAX and TurboLinks. They don't replace the entire HTML of the page, but the body and title tags, as well as other meta tags, and the URL. They don't work crossdomain.

The idea behind these libraries is to speed up page load times by preventing the browser from having to request assets again, usually found in the head.

They also employ some caching strategies to give the page an almost instance response.

Mohamad
  • 34,731
  • 32
  • 140
  • 219
0

How about this...?

 $(document).ready(function () {
    var url = "<iframe src ='http://www.asp.net' style='width:100%;height:100%;margin:0;padding:0;'></iframe>";
    $('body').append(url);
});