varnow=eval (data.data);//Now.sort (sortby (' Bigidorder ', True, parseint)); varTab= ""; varK=0; varHangye=0; varindex = 0;//alert (json.stringify (now[i)); for(vari=0;i<now.length;i++) {Index++; if(now[i].bigid!=Hangye) { if(i==0){//the beginning of the first tabletab + = ' <table id= ' tab ' +k+ ' > '; tab+ = ' <tr><th> Industries </th><th> brands </th><th> frequency (Times) </th><th> duration (seconds) </th ></tr> '; } Else{ for(j=5;j>=index;j--) {tab+ = "<tr>"; tab+ = "<td >--</td>"; tab+ = "<td >--</td>"; tab+ = "<td >--</td>"; tab+ = "<td >--</td>"; tab+ = "</tr>"; }//End of previous table//the beginning of the next tabletab + = ' </table> '; tab+ = ' <table id= ' tab ' +k+ ' > '; tab+ = ' <tr><th> Industries </th><th> brands </th><th> frequency (Times) </th><th> duration (seconds) </th ></tr> '; Index= 1; } Hangye=Now[i].bigid; }//row of the current table //Hangye = Now[i].bigid if(index<6) {tab+ = "<tr>"; tab+ = "<TD >" +now[i].bigindustryname+ "</td>"; tab+ = "<TD >" +now[i].brandname+ "</td>"; tab+ = "<TD >" +now[i].pinci+ "</td>"; tab+ = "<TD >" + (now[i].timesize*1). toFixed (2) + "</td>"; tab+ = "</tr>"; } } for(j=5;j>index;j--) {tab+ = "<tr>"; tab+ = "<td >--</td>"; tab+ = "<td >--</td>"; tab+ = "<td >--</td>"; tab+ = "<td >--</td>"; tab+ = "</tr>"; } tab+ = "</table>"; // }$ (". Industrybrandtrendsubtab"). html (tab);
Sort JSON array objects-the same elements with the same key, the number of groups is inconsistent, you can use the following JS to loop the table output