我正在使用以下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>
答案 0 :(得分:1)
JavaScript的alert()
具有可包含的最大文本量。如果要检查大量文本,有两个选项:
console.log(text)
div
document.getElementById("divID").innerHTML = text
醇>