views:

162

answers:

4

My code is working fine in FireFox but my users are restricted to IE. I'm getting an error though in IE, related to my JQUERY function.

 populateTable:function(returnList) {


     var self = this;
     var eat = $.evalJSON(returnList.firstChild.textContent)
     $.each(eat,function() {


$("<tr><td>" + this.reportId + "</td><td>" + this.description + "</td><td>" + 
this.drawingNumber + "<td></tr>").insertAfter(self.tblResults[0].childNodes[1]);

 })


}

IE is erring on the $.each with the message below:

'Length' is null or not an object

Any ideas or maybe a workaround for the $.each function?

Update: returnList is an XML document object from an Ajax call. I'm trying to retrieve the JSON object string located within the XML tag.

A: 

Your last closing "td" tag is missing a slash

Pointy
correct but not helping my error
Collin Estes
+3  A: 

Your problem probably lies in this line

returnList.firstChild.textContent

Since returnList is a XML DOM object, Internet Explorer traverses and accesses the content different from the rest of the real world (i.e. FF, etc). So, I would put in some more jQuery to do the leg work for you.

$(returnList).find('string').text();

This should return you your JSON string in all browsers supported by jQuery.

Also, if you are trying to insert a row, you are going about it in a strange way. Assuming self.tblResults[0] is the table DOM object you want to append your row to, try this:

$(self.tblResults[0]).append("<tr><td>" + this.reportId + "</td><td>" + this.description + "</td><td>" + this.drawingNumber + "</td></tr>");
Travis Johnson
This fixed the problem.
Collin Estes
A: 

If tblResult is a table, it will have only one child node, a <tbody> in IE (at least sometimes, I don't know if it's always the case).

erikkallen
A: 

If you have date picker on page? And you using asp.net? then this is the solution for it. http://praveenbattula.blogspot.com/2009/09/jquery-datepicker-problem-on-date.html

Rare Solutions