我在下面的代码中遇到了问题。它在firefox v50.X上运行完美,但在chrome v55.X上无效。
HTML
<!doctype html>
<html>
<head>
<script>
function load(){
if(window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("container").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "name.html", true);
xmlhttp.send();
}
</script>
</head>
<body>
<input type="submit" onclick="load();">
<div id="container"></div>
</body>
</html>
name.html
<html>
<body>
<p>Test.</p>
</body>
</html>
为什么这段代码不能用于Chrome?