将外部div内容加载到我的页面div中
问题描述:
我正在尝试将外部网站#external-div内容加载到#mydiv div上的页面上.我已经尝试通过附加此jQuery
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>
脚本是
<script>
$(document).ready(function(){
$('#mydiv').load('http://localhost/qa/ask #external-div');
});
</script>
我的div
<div id="mydiv">loading...</div>
我已从此处但是它没有加载任何东西.
But its not loading anything.
答
尝试下面的代码以获得回调响应:
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);
}
});