刚开始写AJAX代码的时候,直接参照的是AJAX基础教程一书中的代码(该书真的很不错,是AJAX入门的经典教材,是图灵出版社的。计算机方面的书籍,我最信任的就是O'R和图灵的)。
该书的创建XMLHttpRequest对象的代码如下:
03 |
function createXMLHttpRequest()
|
05 |
if (window.ActiveXObject)
|
07 |
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
|
09 |
else if (window.XMLHttpRequest)
|
11 |
xmlHttp = new XMLHttpRequest();
|
在一般情况下,该代码的使用不会带来任何问题。
如:
03 |
createXMLHttpRequest();
|
04 |
xmlHttp.onreadystatechange = handleStateChange1;
|
05 |
url = "test.php?ts=" + new Date().getTime();
|
06 |
xmlHttp.open("GET", url, true);
|
相关文章:
-
2021-06-26
-
2021-11-11
-
2021-07-15
-
2021-12-05
-
2021-10-22
-
2021-04-19
-
2022-12-23
-
2022-12-23