Computers, Javascript, Programming, Technology, Web Programming

AJAX problems in IE

<![CDATA[One of the things I'm working on right now (at work interestingly enough) uses a fairly simple JavaScript function that takes a url and an element id and replaces the content of that element with whatever the url returns.

This worked well until I started getting an odd error from IE – "Unknown runtime error". Firefox and Opera both handled this fine. After some fiddling I discovered the problem was the type of element I was replacing into – Internet Explorer doesn't like you replacing the innerHTML of certain elements. So far I’ve found TR and TBODY don’t work (and I’d guess THEAD and TFOOT too).]]>

Advertisements

23 thoughts on “AJAX problems in IE

  1. <![CDATA[im using ajax to implement "Forgot username and password" functionality in my application and my javascript methods look somewhat like this

    var xmlHttp

    function showCustomer(str)
    {
    alert("In js method");
    alert(document.getElementById("user").innerHTML);
    document.getElementById("user").innerHTML = "Please Wait……"
    //alert(document.getElementById("txtHint").innerHTML);
    var url="/ForgotUsernameandPassword_V1.2.jsp";
    //alert(str);
    xmlHttp=GetXmlHttpObject(stateChanged)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
    }

    function stateChanged()
    {
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
    document.getElementById("user").innerHTML = xmlHttp.responseText ;
    }
    }

    function GetXmlHttpObject(handler)
    {
    var objXmlHttp=null

    if (navigator.userAgent.indexOf("Opera")>=0)
    {
    alert("This example doesn't work in Opera")
    return
    }
    if (navigator.userAgent.indexOf("MSIE")>=0)
    {
    var strName="Msxml2.XMLHTTP"
    if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
    {
    strName="Microsoft.XMLHTTP"
    }
    try
    {
    objXmlHttp=new ActiveXObject(strName)
    objXmlHttp.onreadystatechange=handler
    return objXmlHttp
    }
    catch(e)
    {
    alert("Error. Scripting for ActiveX might be disabled")
    return
    }
    }
    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
    objXmlHttp=new XMLHttpRequest()
    objXmlHttp.onload=handler
    objXmlHttp.onerror=handler
    return objXmlHttp
    }
    }

    it is displaying please wait method in a bold tag i.e,

    but it is showing the following error message on further parsing

    Line: 22
    Char: 2
    Error: Unknown runtime error
    Code: 0

    Please help to solve this
    i doubt the error is at parsing the xmlhttpobject response text
    thanks in advance]]>

    Like

  2. Since that looks like an IE error have you tried it an other browser? IF it works then it could be a similar problem to the one I had. What type of tag is “user”?

    Like

  3. i rn the latest versions of ie, firefox, opera. i wrote a small ajax script, this worked fine in all three browsers. i haven’t changed any settings in any browser, or performed and updates – and suddenly the code stopped working in ie. i don’t see how this can be?

    Like

  4. I had the same problem. My js with ajax works on Safari and Firefox with no problem, but same unknown problem reported with IE 6/7. I spent a few hours trying and googling. I use spans with id inside a TD, and div with ID. Changing the order of the xml tree solved my problem, don’t know why IE does not like certain tags first. Perhaps this silly solution can help anyone. (once again, i don’t like IE, lot of time waste)

    Like

  5. I had the same problem. My js with ajax works on Safari and Firefox with no problem, but same unknown problem reported with IE 6/7. I spent a few hours trying and googling. I use spans with id inside a TD, and div with ID. Changing the order of the xml tree solved my problem, don’t know why IE does not like certain tags first. Perhaps this silly solution can help anyone. (once again, i don’t like IE, lot of time waste)

    Like

  6. WOW, after reading through all of this I replaced my table and my ajax call to replace with divs (styled like table cells) and replaced the divs with the ajax call. Imagine that, Microsoft went far enough to allow updating of but not !!! This is the biggest frustration I have faced with IE so far. From now on I will try to avoid tables altogether. Tables suck but m$ suck worse! Hopefully chrome is adopted by the masses very quickly.

    Like

  7. I am using span tag in my application and changing its content dynamically with that of xmlHttp.responseText. It is giving me javascript runtime error in IE browser but in Firefox it works fine. I tried changing span to div but no success.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s