我正在使用以下内容JavaScript/Ajax
来阅读页面内容,这个脚本效果很好,但它只加载了一半的页面内容shoppingcart.asp
,我希望shoppingcart.asp
完全加载然后显示所有网页内容,这可能吗,我应该添加延迟吗?
<script language="Javascript">
var anUrl = "http://www.abc.com/shoppingcart.asp";
var myRequest = new XMLHttpRequest();
callAjax(anUrl);
function callAjax(url) {
myRequest.open("GET", url, true);
myRequest.onreadystatechange = responseAjax;
myRequest.setRequestHeader("Cache-Control", "no-cache");
myRequest.send(null);
}
function responseAjax() {
if(myRequest.readyState == 4) {
if(myRequest.status == 200) {
result = myRequest.responseText;
alert(result);
alert("we made it");
} else {
alert( " An error has occurred: " + myRequest.statusText);
}
}
}
</script>