I want that this div refresh every 15 seconds, it already refresh, the thing is that it refresh once, the next time that refresh the table its removed and i dont know why :(
<div class="refresh">
<table class="editinplace">
<tr>
<th>id</th>
<th>Nombre</th>
<th>Apellidos</th>
<th>Telefono</th>
<th>Status</th>
</tr>
</table>
</div>
And this is the ajax where append the json
var auto_refresh = setInterval(
function ()
{
$('.refresh').load('index.html');
}, 10000); // refresh every 10000 milliseconds
$(document).ready(function()
{
$.ajax({
type: "GET",
url: "editinplace.php?tabla=1"
})
//Vector
.done(function(json)
{
json = $.parseJSON(json)
for(var i=0;i<json.length;i++)
{
$('.editinplace').append
(
"<tr><td class='id'>"
+json[i].id
+"</td><td>"
+json[i].nombre
+"</td><td>"
+json[i].apellidos
+"</td><td>"
+json[i].telefono
+"</span></td><td class='editable' data-campo='status'><span>"
+json[i].status
+"</span></td></tr>");
}
});
$(document).ready(function(){
setInterval(function(){
$('div').ajax({
url: "test.php",
}).done(function() {
$(this).html( "done" );
});
}, 15000); // 15000 micro second = 15 sec.
});
URL will be the name of the php file. You can also specify the name of the DIV
Here refresh_div()
function call at every 15 seconds
.
function refresh_div()
{
// Your ajax code here
}
setInterval('refresh_div()', 15000);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.