views:

37

answers:

2

I'm having IE give me this error for a small function I wrote:

Message: Object expected Line: 13 Char: 52 Code: 0

Here is my code (please excuse the formatting):

function SectionTwo()
{
    if (xmlhttp.readyState==4) {
        if( xmlhttp.status==200 ) {
            if( xmlhttp.responseText.indexOf( "404 Error" ) >= 0 ) { } 
            else {
                var idtagsArray = ["KT501-1_8","KT502-15_30","KT503-15_37","KT504-10_30","KT505-30_80","KT506-30_90","KT507-20_50","KT510-15_1440","KT512-0_1_2_3_4","KT513-30_80","KT514-0_1","KT520-0_1","KT525-0_1_2","KT526-0_1","KT527-0_9999","KT529-0_9999","KT531-0_9999","KT533-0_9999","KT535-0_250","KT536-0_9999","KT538-0_9999","KT548-0_1","KT549-0_1","KT550-102_120", "KT551-80_98","KT552-15_37","KT553-0_30","KT554-50_90","KT555-20_50","KT565-0_10","KT566-0_20","KT567-0_30","KT568-0_50","KT569-1_10","KT570-1_10","KT571-2_10","KT572-2_10","KT573-1_20","KT574-1_30"];
                for(var tag = 0; tag < idtagsArray.length; tag++) {
                    UpdateImage( idtagsArray[tag], xmlhttp.responseText);
                }
            }
        }
    }
}

The last line is line 13. I also have another function called SectionOne which is identical to the above except that it calls UpdatePoint instead of UpdateImage, and that one does not error out.

Chrome and Firefox do not show any JS errors and work as intended. Here is the UpdateImage function:

function UpdateImage( usediv, data )
{
    if( data == null || data.length <= 0 ) {
        update_value.innerText = 0;
        return
    }

    // [A5:1][A6:1][A7:1][A8:1]
    var start       = data.indexOf( "[" + usediv + ":" ) + 2 + usediv.length ;
    var end         = data.indexOf( "]", start );
    var data_value  = data.slice( start , end ) ;

    if( data_value > 0 )
    {
        document.getElementById(usediv).style.display = "";
    }
    else
    {
        document.getElementById(usediv).style.display = "none";
    }
}

Any ideas would be appreciated.

A: 

Could it be the lack of a semi-colon on the return in UpdateImage?

Edit:

In that case you just have some obscure syntax oddity that IE is confused about (happens all the time :)).

Start removing code. Get rid of all those nested if's (probably should be refactored anyway). Don't do a for loop, just call UpdateImage( idtagsArray[0], xmlhttp.responseText ). Make your idtagsArray only 1 element long. Etc.

thenduks
It's not that, although I missed it thanks. The error still occurs when I make UpdateImage a stub function with no code.
xcosminel
A: 

Could it be the missing semicolon after return in your function UpdateImage?

Timwi