hi guys ! i have a function that count the number of message in the data base i whant when i get a message the number get refreshed automaticly so i whant to repeat this function every 5 seconds.
hi guys ! i have a function that count the number of message in the data base i whant when i get a message the number get refreshed automaticly so i whant to repeat this function every 5 seconds.
set javascript timeout function to make ajax request to your method that returns result.
call a two ajax on same page.In first ajax call a second ajax function and return the set response by first ajax so every time when data return ajax will call automatically.
for ex…
First Ajax:
$.ajax({
type: "POST",
url: '<?php echo Yii::app()->createUrl('/admin/bridgeOrder/runConsole')?>',
data: $('#bridge-order-form').serialize(),
dataType: "json",
success: function(data){
reponseLoader(data);
}
});
function reponseLoader(dataReq){
$.ajax({
type: "POST",
url: '<?php echo GxHtml::normalizeUrl(array('/admin/bridgeOrder/getResultRun'))?>',
data: dataReq,
dataType: "json",
success: function(data){
$('.response').html(data.html);
if(data.completed>0) {
$('.button-box').show();
$('#ajax_process_loader').hide();
$('.btn_back').show();
return false;
}
setTimeout(function() {
reponseLoader(dataReq);
}, 1000);
},
});
}