Load external div content to my page div

余生颓废 提交于 2019-11-28 02:05:47

问题


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:


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);
      }
});


来源:https://stackoverflow.com/questions/12938386/load-external-div-content-to-my-page-div

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!