1

How can I load a webpage from a different domain in a div in a .asp page? I´m using the below and both works, it loads a div from one page on my domain into another page on my domain. But how can I do this if it is another domain?

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type="text/javascript" src="js/jquery.xdomainajax.js"></script>
<script type="text/javascript">
$(document).ready(function(){

    $('#external').load('http://www.mypage.com/page2.html #page2'); 


    $('#mydiv').load('http://www.mypage.com/page2.html #page3', function(response, status, xhr) {
    if (status == "error") {
        var msg = "Sorry but there was an error: ";
        alert(msg + xhr.status + " " + xhr.statusText);
      }
});    
});
</script>
</head>
<body>
<div id="external"></div>
<br><br>
<div id="mydiv"></div>
</body>
</html>

Thanks!

Claes Gustavsson
  • 5,509
  • 11
  • 50
  • 86
  • 1
    Look at [this post](http://stackoverflow.com/questions/7177080/how-do-i-load-an-url-in-iframe-with-jquery) to load content into an iframe (same origin policy doesn't apply for iframes) – Alepac Apr 26 '13 at 12:35
  • I know how to do it in .php, but not in .asp (0 exp) I don't know if it will be useful for you... lemme know – Roko C. Buljan Apr 26 '13 at 12:35
  • Hi Alepac, I know how to do it with an iframe, but thats not what I want right now. – Claes Gustavsson Apr 26 '13 at 12:37
  • Hi roXon, I have found some examples with php, but thats not an option I´m afraid. I need to get it to work with .asp – Claes Gustavsson Apr 26 '13 at 12:39

0 Answers0