简体   繁体   中英

can't load ajax on IE6 & IE7

The code below is an ajax create function which is written in JS.

this works on Firefox , Safari and Chrome perfectly but doesn't work on IE6 & IE7 .

How can fix my code to load 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

1) JQuery

2) Mootools

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.

Read up more on jQuery AJAX here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM