JavaScript 代码无法跨浏览器运行

标签 javascript html internet-explorer google-chrome

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/

相关文章:

javascript - 是否可以更新 Mongoose 文档中的对象?

javascript - 由 google charts js 提供的自定义圆环图

javascript - 如何分别使用 jQuery 分隔字符串中的元素

html - CSS 向右移动图标

JavaScript IE appendChild() - 意外调用方法或属性访问

javascript - Angular.js $scope 在 $http 之后未绑定(bind)

javascript - 忽略 javascript 调试器中的 onMouseMove

javascript - 使用 IFSc 进行游戏开发 - 代码分离

internet-explorer - 如何在不使用任何虚拟以及第三方工具的情况下在同一台机器上运行多个版本的 IE(IE10、IE11)

javascript - IE : onproperty change triggered when binding the handler by DOM element properties