Creating body of Table creates error
Hi, Getting error trying to create table. Don't know what it is or how to fix it.
Hope someone can help.
- //////// CREATE HEADERS for Table ///////////
// pData from Ajax Call
table_str="<table class='center' border='3' cellpadding='5' bgcolor='#fff99d' >";
table_str+="<thead><tr>";
$.each(pData, function(index, value) {
if (index>0) return false; // just to get the headers
$.each(value, function(i, val) {
table_str+="<th>"+i+"</th>";
});
});
/////////// CREATE Body ////////////////
table_str+="<body>";
$.each(pData, function(index, value) {
table_str+="<tr>";
$.each(value, function(i, val) {
table_str+="<td>"+val+"</td>"; // line of data 'val' Creates the error as below
});
table_str+="</tr>"; // end row
});
table_str+="</body></table"; // end table
alert(table_str);
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ERROR ERROR
TypeError: invalid 'in' operand obj
error source line:
typeof length === "number" && length > 0 && ( length - 1 ) in obj;
jquery-2.1.1.js (line 547, col 3)
*/