javascript - Creating HTML table from json data -
i trying display json data on browser in tabular form dynamically. have 2 json data.
{"status": "success", "jpgname": "/home/demo/ui/public/upload/imgname.jpg", "actual": "normal", "filename": "filename.txt"}
and second json data file :
{"age": 33, "sex": "male"}
i want combine both json data single table. problem both json data output of python script. python script take n number of text files input , produces json output. facing problem is, table cells getting updated fields of first json data, example 5 text files have loaded, 5 first json data file , 5 second json file. table getting updated fields of first json data file first , going second json file. can body me, how parse json data , update table cells json field values. want both first , second json data there in same row. second row second set of json files.
<table> <tr> <th>thumbnail</th> <th>actual</th> <th>status</th> <th>age</th> <th>sex</th> </tr> </table> var table = document.createelement('table'); var obj = json.parse(data); var tr; tr = $('<tr/>'); tr.append("<td>" + "<img src = /upload/" + obj.filename + ".jpg" + " alt=img/>" + "</td>"); tr.append("<td>" + obj.actual + "</td>"); tr.append("<td>" + obj.status + "</td>"); tr.append("<td>" + obj.age + "</td>"); tr.append("<td>" + obj.sex + "</td>"); $('table').append(tr);
Comments
Post a Comment