var txt = http.responseText; -> 它在 Chrome 中不起作用... 我怎样才能改变这条线?
最佳答案
您应该在最后调用方法发送:
var http = new XMLHttpRequest();
var url = "http://example.com/logScore.php";
var params = "GameID=5&User="+name+"&Score="+score+"";
http.open("GET", url+"?"+params, true);
http.onreadystatechange = function() {//whatever you want}
http.send();
不调用发送请求将不会发送。
关于JavaScript 代码无法跨浏览器运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20389093/