views:

218

answers:

2
function addRequest(req) {
try {
    request = new XMLHttpRequest();
} catch (e) {
    try{
        request = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){        
        try {
            request = new ActiveXObject("Microsoft.XMLHttp");
        } catch (e) {
            alert("XMLHttpRequest error: " + e);
        }
    }
}
request.open("GET", req, true);
request.send(null);
return request;

}

As you can see, it IE apparently fails all 3 ways in which I try to make the request. I've been doing plenty of searches to try and find what may be the issue, but by all accounts ive read, the code ive posted above should work.

i havent used jquery for AJAX, but ive seen it recommended when others have had issues with httprequest objects. could i just replace the mess above with a couple lines of jquery and assume that it will take care of IE's ugliness?

Thanks!

+1  A: 

Different versions of IE have different ways of referring to the XMLHTTP object.

It has to do with the MSXML libraries installed on your machine. What OS/IE version are you running?

Try running Windows Update. An odd solution, but one that may work here.

Moshe
I'm running Windows 7 with IE8. I'm in the process of running windows update, but i just tried it on another box with vista/ie7 and it failed there as well. heres a link to my site: http://la.truxmap.com/request?id=boolbbqto test it out for yourself, either enter a new address and click submit, or click on the star. Thanks for your help Moshe!
culov
I'm on Mac right now, can't test it! Glad to see you've sorted things out though. By the way, I'm curious to see if Windows Update helped. It could be that Windows Update would install an XML Parser that is *too new* relative to your coda and thus be called by a name not referenced in the currently available tutorials online.
Moshe
+3  A: 

i havent used jquery for AJAX, but ive seen it recommended when others have had issues with httprequest objects. could i just replace the mess above with a couple lines of jquery and assume that it will take care of IE's ugliness?

Short answer: yes.

Although jquery syntax does things differently so you won't be explicitly creating a request and sending it. Its all wrapped up in a function. E.g. from http://api.jquery.com/jQuery.get/

$.get("test.cgi", { name: "John", time: "2pm" },
   function(data){
     alert("Data Loaded: " + data);
   });

You can forget about browser interoperability problems. As long as you stay up to date with jquery releases :) love it

Jacob