XMLHttpRequest Div problem with IE

February 28th, 2007 | by Kennith |

XMLHttpRequest is been better known as Ajax, where you might have used it in application such as Google Map.

So, I was also into building this type of application on the projects at hand to increase the level of user friendliness.

When developing a web application, it is always a practice to test between the most popular browser namely, IE and Firefox. (For more detail-oriented programmer, it will be included several other browsers such as Opera, etc.)

Anyway, enough said about it.

When I was writing up a piece of code, I usually run it with Firefox with the Firebug to debug any problem. Once it’s bug free in _Firefox_, then it will be time to run in IE. 3 out of 5 times, there will be a Error showing at the left bottom corner of the IE. It frustrate me a lot because without any useful information, it just say: Error.

So, this time, I was writing a piece of code that will do Ajax to update information from one Div to another Div. As usual, I got no problem on Firefox. It runs perfectly and bug free. As usual again, the IE is giving me some mystery to solve. This time, the error is called, “Unknown run time error.” Great, isn’t it?

So, I was poking around, thinking it’s a JavaScript error. I applied the try and catch to capture any error that is possible to catch, no luck. I thought it was my XMLHttpRequest’s problem, no luck neither. Scratching my head until all the dust came down to my keyboard and still no answer. Staring at the error that IE gave me was so encouraging on knowing what to fix. Then I did the unexpected…

I switch the order of the DIVs.

Before:

After:

and it WORKS! What in the world happen!?

Would it be nice for IE to say, “Object not found” instead of “Unknown run time error” ? It is clearly shown that the action part cannot find the result section to display result because it is declared after the action part.

I have to say the error was not obvious and I was not expecting this kind of thing is an error. It is good to note about this and I hope it will be helpful for those who see “Unknown run time error” as a hint of what to “fix.”

Post a Comment