Load external div content to my page div

2019-01-26 00:52发布

I am trying to load external website #external-div content to the page on #mydiv div. I have tried by attaching this jquery

<script src="js/jquery-1.8.2.min.js"></script>

and script is

<script>
    $(document).ready(function(){
        $('#mydiv').load('http://localhost/qa/ask #external-div');
    });
</script>

My div

<div id="mydiv">loading...</div>

I have downloaded jquery from here http://jquery.com/download/?rdfrom=http%3A%2F%2Fdocs.jquery.com%2Fmw%2Findex.php%3Ftitle%3DDownloading_jQuery%26redirect%3Dno

But its not loading anything.

1条回答
霸刀☆藐视天下
2楼-- · 2019-01-26 01:20

try code bellow to get callback respon:

$('#mydiv').load('http://localhost/qa/ask #external-div', function(response, status, xhr) {
    if (status == "error") {
        var msg = "Sorry but there was an error: ";
        alert(msg + xhr.status + " " + xhr.statusText);
      }
});
查看更多
登录 后发表回答