AJAX problem on IE7

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • agun
    New Member
    • Oct 2008
    • 16

    AJAX problem on IE7

    Hello,

    I'm having problem implementing AJAX on IE7. In other browser it works totally fine. In IE7, if i enable the Enable Native XMLHTTP support, everything just went wrong.

    Here is the XMLHTTP request code : (thanks to www.masykur.web.id)

    ----------------
    Code:
     http_request = false ;
            if (window.XMLHttpRequest) { 
                http_request = new XMLHttpRequest();
                if (http_request.overrideMimeType) {
                    http_request.overrideMimeType('text/xml');
            
                }
            } else if (window.ActiveXObject) { // IE
                var aVersions = [ "MSXML2.XMLHttp.6.0", "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "Microsoft.XMLHTTP" ];
                for (var i = 0; i < aVersions.length; i++) {
                    try { http_request = new ActiveXObject(aVersions[i]);
    					break;
                    }
                    catch (e)
                    {
                    // Do nothing 
                    } 
                }
            }
    ------------

    But if i disable the Enable Native XMLHTTP support, it just run smoothly.
    I've read from several forums that this problem is quite common, but i just can't find out the work-around.


    How do i overcome this problem?
    Since out there i can't tell the IE7 user to 'disable their XMLHTTP native'.
    Btw, i guess in IE6 there's no problem at all.

    Thanks...
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    some ways I would try to solve this:
    - try-catch on both objects
    - try the ActiveXObject first

    this one is working fine for me:
    [CODE=js] try {
    request = new XMLHttpRequest( );
    }
    catch (e){
    try {
    request = new ActiveXObject(" Msxml2.XMLHTTP" ); // IE 5
    } catch (e) {
    try {
    request = new ActiveXObject(" Microsoft.XMLHT TP"); // IE 6
    } catch (e) {
    alert("...your error message here...");
    return false;
    }
    }
    }[/CODE]

    must proceed, will check later

    regards

    Comment

    Working...