XMLHttpRequest.open 方法上 async 属性的 javascript 默认值是什么?

Jef*_*Jak 4 javascript xmlhttprequest

我发现 IE6 和 Firefox 7 之间的结果不同。我认为对于不同的浏览器,差异可能不会那么大,因为 IE6 的大部分使用 ActiveX 控件,而其他所有内容都使用 XMLHttpRequest。我相信 XMLHttpRequest 在 IE7 之前并不是原生的。

在 IE6 ActiveXObject 和 Firefox 7 中似乎是错误的。但我似乎找不到文档。

// one of these lines gets called - the first successful one
obj = new XMLHttpRequest();
obj = new ActiveXObject("Msxml2.XMLHTTP.3.0");
obj = new ActiveXObject("Msxml2.XMLHTTP");
obj = new ActiveXObject("Microsoft.XMLHTTP");
// now later the code makes this call
obj.open("GET",url);
// notice how the third parameter [async] is not assigned
Run Code Online (Sandbox Code Playgroud)

我的问题是在上述不同场景下 async 属性的默认值是什么?

pra*_*eek 5

默认为 true。请参阅文档。

另外,您创建 XMLHttpRequest 对象的方式是错误的。每个语句都会覆盖 obj 变量。请参阅以了解正确的方法。