Requirements Testing

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.

OR

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!

Written by Tim on October 25th, 2006 with 11 comments.
Read more articles on asp.net and web 2.0 ish.



Related articles

11 comments

Read the comments left by other users below, or:

Get your own gravatar by visiting gravatar.com Eric Lawrence [MSFT]
#1. October 25th, 2006, at 8:54 PM.

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.

Get your own gravatar by visiting gravatar.com Tim
#2. October 25th, 2006, at 9:10 PM.

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.

Get your own gravatar by visiting gravatar.com Tim
#3. October 26th, 2006, at 7:15 PM.

I found this today explaining the difference of the new XmlHttpRequest oject verses the old Microsoft.XMLHTTP object.

http://blogs.missiondata.com/?p=64
His thought is that IE 7 doesn’t reuse the javascript for every request, like Microsoft.XMLHTTP does. This maybe a problem with the ajax framework I am using - Ajax Professional - http://www.ajaxinfo.net…. More to come on this issue.

Get your own gravatar by visiting gravatar.com Tim
#4. October 27th, 2006, at 3:01 PM.

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);

Get your own gravatar by visiting gravatar.com Anthony
#5. November 13th, 2006, at 8:08 PM.

This article answered my question and now I am not having any problems.

Get your own gravatar by visiting gravatar.com Cobold
#6. November 30th, 2006, at 10:49 AM.

Thank you very much, this article saved me hours! Stupid Microsoft and Ie

Trackback Mention from Blog.15minutesmedia.com
#7. December 3rd, 2006, at 8:01 PM.

15 minutes media » The Release of IE7 and what it means for website owners: AJAX XMLHTTP: The IE Blog says: “to have your cross-browser AJAX work better with IE7, you really should be ...

Trackback Mention from Conversationing.com
#8. September 13th, 2007, at 5:43 AM.

conversationing » Blog Archive » Today is brought to you by the letters AJAX and IE7: are also concerns of it being much slower and buggier than XMLHTTP is. I guess a new implementation is ...

Get your own gravatar by visiting gravatar.com Dan
#9. December 27th, 2007, at 7:22 AM.

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.

Get your own gravatar by visiting gravatar.com Sean
#10. June 12th, 2008, at 2:57 AM.

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!

Get your own gravatar by visiting gravatar.com Ralf
#11. July 6th, 2008, at 6:41 AM.

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

Leave your comment...

If you want to leave your comment on this article, simply fill out the next form:




You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> .