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 pare 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
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 pare 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
Share Improve this question edited Feb 15, 2010 at 16:13 jonnyhitek asked Feb 15, 2010 at 16:03 jonnyhitekjonnyhitek 1,5614 gold badges19 silver badges31 bronze badges 4- all vars in full 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); – jonnyhitek Commented Feb 15, 2010 at 16:10
- As I asked in my answer, what format is the date in, and are you sure that it is always in that format? – Paul Manzotti Commented Feb 15, 2010 at 16:15
- the date/ time is in java dateTime format – jonnyhitek Commented Feb 15, 2010 at 16:24
- yes it will always be in that format - cheers – jonnyhitek Commented Feb 15, 2010 at 16:25
6 Answers
Reset to default 2Your 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.
insert alert(timeCheck);
before the offending line and i supect you will find that it is undefined.
You could try putting in a check that dateCheck.length is 2. Where is noteDate ing from, and is it always in the format dateTtime (is it in ISO date format?).
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.
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.
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./ticket/3143
and also changing the data type in the ajax request from xml - text.
cheers for everyone who inputted to this thread
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745303373a4621572.html
评论列表(0条)