Reputation: 5799
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.
Upvotes: 1
Views: 3516
Reputation: 11
I had the same problem using jquery 1.6.2.
I changed in the jquery (minimized version), the each
method to make workaround until they fix the bug (Ticket #9974) and it worked great for me.
At char 12361 on jquery-1.6.2.min.js i added this condition: if(!a)return;
So the code from this char looked like :
each:function(a,c,d){if(!a)return;var f,g=0,h=a.length,i=h===b||e.isFunction(a);
instead of:
each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);
Hope it helps someone.
Upvotes: 1
Reputation: 811
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>");
Upvotes: 3
Reputation: 34411
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).
Upvotes: 0