[英]can't load ajax on IE6 & IE7
The code below is an ajax create function which is written in JS. 下面的代码是一个用JS编写的ajax创建函数。
this works on Firefox
, Safari
and Chrome
perfectly but doesn't work on IE6
& IE7
. 这适用于Firefox
, Safari
和Chrome
,但不适用于IE6
和IE7
。
How can fix my code to load ajax? 如何修复我的代码加载ajax?
function ajaxCreateRequest() {
var request = false;
if(window.XMLHttpRequest) {
request = new XMLHttpRequest;
}
else if(window.ActiveXObject) {
request = new ActiveXObject("Microsoft.XMLHTTP");
}
if(!request)
alert("This Browser doesn't support my page!");
return request;
}
Whilst I do not foresee/observe any conspicuous issue in your above posted code, why not use existing javascript framework (they make up excellent javascript abstractions) like 虽然我没有预见/观察上面发布的代码中的任何显着问题,但为什么不使用现有的javascript框架(它们构成优秀的javascript抽象)
3) Prototype.js 3) Prototype.js
If you try to write this on your own by using the archaic code that you have posted above, you'll have to burn your fingers while making it cross-browser compatible. 如果您尝试使用上面发布的古老代码自行编写,则必须在使其与浏览器兼容的同时刻录手指。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.