jason jason - 1 year ago 83
Javascript Question

JSON object reproduces itself

I have this JSON which generates a table :

function show(json)
var content = '<table id = "myTable" border = 1>';
var counter;

for(counter = 0; counter < json.length ; counter++)
content += '<tr><td class = "topics">' + json[counter]['topic_name'] + '</td>''</tr>';
content += '</table>';



I call it two times :
1st. here :

$.getJSON("admin.php", show);

Second when I add something on the table:

When I add something, the new table appears below the old one, I want to lose the old one and see only the new one. How can I do it?

Answer Source

try to change




this will replace the entire content of #table_here element

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download