我正在尝试将外部网站#external-div内容加载到#mydiv div上的页面.我试过附上这个jquery
< script src =“js / jquery-1.8.2.min.js”>< / script>
和脚本是
<script> $(document).ready(function(){ $('#mydiv').load('http://localhost/qa/ask #external-div'); }); </script>
我的div
< div id =“mydiv”> loading …< / div>
我从这里下载了jquery http://jquery.com/download/?rdfrom=http%3A%2F%2Fdocs.jquery.com%2Fmw%2Findex.php%3Ftitle%3DDownloading_jQuery%26redirect%3Dno
但它没有加载任何东西.
解决方法
尝试使用代码来获得回调响应:
$('#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); } });