jQuery - Create table from JSON data
I'm trying to update a table based on the results of a database query returned via JSON. My goal is to show the progress of a queue, removing entries that have completed. Firstly I need to populate a table with the results of the JSON. I have:
- <HTML>
<HEAD>
<TITLE>Table Update Test</TITLE>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
setTimeout("updateTable();", 10000);
function updateTable()
{
$.post("test.pl", {}, function(result) {
alert(result);
$("#txtJSON").val(result);
$("#jobtable").html(result);
});
setTimeout("updateTable();", 10000);
}
</script>
</HEAD>
<body>
<table id='#jobtable'>
<input type='text' id='txtJSON'>
</table>
</body>
</html>
My JSON date looks like:
- {"myData":[ {"REC_NO":"107045","JOB_ID":"1","JOB_TEXT":"Task 1"}, {"REC_NO":"107046","JOB_ID":"1","JOB_TEXT":"Task 2"} ]}
But the table doesn't get populated. Do I need to write some sort of routine to populate the table manually or is there some sort of "built in" way do to it?
Thanks