我做了一个简单的HTML来玩XHR,但没有得到httpxml.responseText的响应; 但该脚本在safari控制台中工作。卡在XMLHttpRequest
<html><head></head><body>
<div id="myDiv"></div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>
<script type="text/javascript">
function loadXMLDoc()
{
httpxml = new window.XMLHttpRequest;
httpxml.open('GET','resources/xml/test.xml',true);
httpxml.send();
text = httpxml.responseText;
alert(text);// there's no text in the alert window
document.getElementById("myDiv").innerHTML=text;
}
</script>
</body>
</html>
哪本书/教程你读这使你错误地接近它? – BalusC 2012-01-10 03:53:21
@BalusC这是W3school的阿贾克斯啧啧,我犹豫了解全面测试并错过了异步点 – mko 2012-01-11 00:58:02