我有以下代码:
var serverRequest = function(){
var request = new XMLHttpRequest();
request.open('GET', 'http://localhost:8080/6ZHYW8/messages', true);
request.addEventListener('load', function(e){
document.write('2');
}, false);
request.send(null);
}
/******************Functions *************************/
serverRequest();
/********************* Runtime Code ********************************/
window.addEventListener('load', function(){
start();
}, false);
在使用谷歌浏览器时,
http://localhost:8080/6ZHYW8/messages
回应:
[
{
"nickname": "\"Administrator\"",
"message": "\"KEEP IT CLEAN. You crazy kids\""
},
{
"nickname": "vanilla",
"message": "THUNDA"
}
]
有人会碰巧知道为什么我的代码永远不会到达“document.write('2')”吗?