views:

277

answers:

6

Hey guys having a strange problem basically all is fine in good old ff however ie7 is crying like a little baby and throwing the above error - char: 3, 'Undefined' is null or not an object .

I am splitting a string into a format I need to compare with another string. Once I have split the string I split it further - example below :

    noteDate = $(xml).find('entry:first published').text();
    // split string to get the date - saved in realDate
    var dateCheck = noteDate.split("T");
    var realDate = dateCheck[0];
    var timeCheck = dateCheck[1]; 
    var lastSplit = timeCheck.substring(0, timeCheck.length-1);
    var fullFeedDT = (realDate + " " + lastSplit); 

IE7 is currently moaning about the forth line however I have a feeling the problem may be with line 3 - due to the fact the error has 3 characters (char: 3).

If anyone can spot a problem please let me know would be greatly appreciated.

Cheers

A: 

insert alert(timeCheck); before the offending line and i supect you will find that it is undefined.

Sky Sanders
timeCheck is defined and brings back the correct value - in ff
jonathan p
A: 

You could try putting in a check that dateCheck.length is 2. Where is noteDate coming from, and is it always in the format dateTtime (is it in ISO date format?).

Paul Manzotti
thanks for your answer - noteDate comes from an XML file (feed) generated by a Java web service so always come back in timeDate format
jonathan p
A: 

Did you make sure "noteDate" does actually contain "T"? The way it looks, "dateCheck[1]" does not contain anything, making "timeCheck" equals "undefined".

You may want to check "timeCheck" for content (via alert or console.log in FF) to investigate.

Select0r
thanks but it is defined - added full code to the example cheers
jonathan p
+2  A: 

Your problem is most probably in the first line:

noteDate = $(xml).find('entry:first published').text();

For some reason, your XML data is not being loaded correctly in IE.

Daniel Vassallo
Cheers, I just tested to see if ie7 could see the data - alas it seems it cannot get the data - did an alert and presents a lovely blank alert box in ie7 - ff still fine. grrrr
jonathan p
I'm going to close this thread - as it seems the issue as you suggested is with the way i am parsing the xml. cheers daniel
jonathan p
don' t forget to mask this answer accepted, if it helped you
Valentin Rocher
A: 

I would first add an alert for each variable in the script to report its value and type (alert((typeof varInstance)+': "'+varInstance+'"');) to make sure its what you expect in IE. Then id go about debugging accordingly. That said Im going to guess that its as Daniel suggests and is an issue with the xml.

prodigitalson
A: 

the problem was not with the way I was parsing the xml etc. but more down to the fact that ie was getting back the xml and putting it in a string format - solved the problem after reading this thread http://dev.jquery.com/ticket/3143

and also changing the data type in the ajax request from xml - text.

cheers for everyone who inputted to this thread

jonathan p