IE 7 – Native xmlHttpRequest Not So Good

When I found out IE7 was going to implement a native javascript object, xmlHttpRequest, in addition to their own Microsoft.XMLHTTP object, I was thrilled. This meant once IE 6 was phased out of the world, all my ajax stuff wouldn’t need to check browser before proceeding. For the most I use ajax frameworks (http://www.ajaxpro.info/) that already have this built in but I do write my own xmlhttp request on occasion.

For an internal application I have an ajax search functionality built that queries a database and returns customers names on key entry. So I type in “Acm” I get a listing of:

Acmanda
Acmat
Acme

This is very similar to Google suggest, but I display the results in a fixed height div tag with auto scroll enabled. The ajax returns li tags with href tags around the company names. This works on IE 6, FF, and Safari. However in IE7, there is some real slowness to this. When I use Fiddler I see the Request returning from the AJAX calls but the results do not show up. I tried setting the page cache to nothing, but still no luck. I then ran into several articles questioning the XmlHttpRequest javascript object.

I also found out IE 7 is slow on some Google sites where a ton of XML traffic is being returned, like their Google Maps.

I started playing around with IE 7’s options, turning off Phishing filter, testing, no luck and so on. When I turned off the native XMLHttp support as seen below, my application ran perfectly fast on IE7. IE 7 is set up to fall back to the Microsoft.XMLHTTP Active X object if this gets turned off.

So this makes me wonder.

  • Did the IE 7 team really implement a native javascript XmlHttpRequest object?
  • If so, did they follow the spec?
  • If so, is their object code buggy or just plain slow

OR

  • Is their native XmlHttpRequest object really a javascript object or did they cut corners and implement an object that acts native but in all reality is a deformed active x object?
  • If so, why would you ship with this option turned on by default?

This has egg on the face written all over it.


Did you know you could browse IE with handheld computers? Modern technology makes everything more portable, like barcode readers and mobile computers. Zebra card printers are now portable, too, so you can print on the go!

Tim

A .NET, PHP, Marketing Guru authority, at least I hope I am. Reach me at tboland@gmail.com

25 thoughts on “IE 7 – Native xmlHttpRequest Not So Good

  1. Without a repro URL, it’s hard to understand where you’re hitting problems.

    Internally, the native object still uses MSXML, which is the same base that the older AX object used. Hence, it would be quite surprising to see slower performance on the new object.

  2. Eric,
    I’ll see if I can get something I can show publicly to demo the difference. Like I said, the http request are being returned with data but IE7 doesn’t display the results with the same performance with the option turned off. I wasn’t aware they are both using MSXML, making wonder if this is a rendering issue.

  3. I got the fix for for my application but I suspect this might be a problem for additional ajax frameworks. It looks like my call back function wasn’t executing for every request (again I believe it has to with IE7 not reusing the same javascript object for each request). I changed to pass the results directly to javascript var object.

    OLD javascript code:

    A_Class.Ajax.Search(keyValue,SearchBy, SearchWord_CallBack);

    function SearchWord_CallBack(response) {
    var word = response.value;
    if(response != null)
    {
    document.getElementById("Display").style.visibility = "visible";
    document.getElementById("Display").innerHTML = word.substring(0,word.length - 4);
    }
    }

    New Code:

    var word = A_Class.Ajax.Search(keyValue, SearchBy).value;
    document.getElementById("Display").style.visibility = "visible";
    document.getElementById("Display").innerHTML = word.substring(0,word.length - 4);

  4. Doesn’t it make perfect sense though? If Microsoft needs to compete with Google to take over IT, then issuing a change that breaks Google’s products is an absolutely fantastic way of levelling the field.

    JSON for the win.

  5. Madness….

    My Ajax program has been working like a charm in firefox, but in IE7 its dog…. You have just saved me….

    I removed the if httpObject is NOT present line like u did.

    Champion!

  6. I can only agree to use Microsoft.XMLHTTP Active X object in IE7 in favor of XMLhttpRequest object. Have been working on a little instant messenger today and the followin code did not work in IE7 with the XMLhttpRequest:

    function refreshIM()
    {
    script = ‘ajax/im_prog.php’;
    querystring = ‘a=refresh&refuid=’ + im_refuid;
    sendHTTPRequest2(script, querystring, ‘get’, refreshIM_callback);
    setTimeout(“refreshIM()”, (im_refresh_interval * 1000));
    }

    the problem was with setTimeout. It simply did not work in IE7 with XMLHttpRequest, only with Microsoft.XMLHTTP.

    There are no problems in Firefox 3 and Opera 9.51

  7. I was very impressed by this post, this site has always been pleasant news. Thank you very much for such an interesting post. Keep working, great job

  8. The knowledge you share really changes me in life, I sincerely thank you for the things you have done, sure your blog will help more people. Sincerely thanks

  9. How long does it take to complete this article? I have read through other blogs, but they are cumbersome and confusing. I hope you continue to have such quality articles to share with everyone!

Leave a Reply

Your email address will not be published. Required fields are marked *