Reload table Ajax jquery -
i developing table , table reload ajax/jquery table doesn't empty , append next content table.
<table class="table" id="pujas"> <thead> <tr> <th>#</th> <th>nombre</th> <th>apellido</th> <th>email</th> </tr> </thead> <tbody> </tbody> </table> jquery
<script> $(document).ready( function() { setinterval(function() { $.ajax({ url:'../ajaxpujas', datatype:'json', type:'get', cache:true, success:json, }); function json(data){ $(data).each(function(index,value) { console.log(value); var table = '<tr><td>' + value.id + '</td><td>' + value.id_user + '</td><td>' + value.importe + '</td></tr>'; $('#pujas').append( table ); }); } }, 1000); }); </script> any idea ? how refresh table correctly?
try:
add tbody id
<tbody id='tbodyid'> and clear before append
$("#tbodyid").empty(); in code
function json(data){ $("#tbodyid").empty(); $(data).each(function(index,value) { ...
Comments
Post a Comment