John Davidson

javascript - What is the best way to display data real-time in index

0 comments
Message:


Everything is good, working, but is this a good way to refresh some data to display in the index, any suggestion will help


$(document).ready(function () {

setInterval(function () {
$.ajax({
url: 'dashboard/reserv_load_today.php',
success: function (data) {
var json = JSON.parse(data);
$('#reserve_today').html(json.TODAY);
}
})

$.ajax({
url: 'dashboard/last_update.php',
success: function (data) {
var json = JSON.parse(data);
$('#last_update').text(json.LAST);
}
})
}, 3000);

});


My Answer:
('#data').html('');_ for (var i = 0; i < json.length; i++) {_ $('#data').append('' + json[i].name + '' + json[i].time + '');_ }_ }_ });_}, 10000);_});

Rate this post

3 of 5 based on 7587 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us