I would like to push data from mysql db to div every x seconds.
at window.setTimeout(update, 60000);
- how to pass in the btnStart.click function into it again???
Not too sure about the syntax for passing in function call.
Here's the code for reference
$('#btnStart').click(function() {
$.ajax({
url: "ajax.php",
type: "POST",
data: 'id=6',
timeout: 15000,
beforeSend: function(){
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$("#userstatus").html('Timeout contacting server..');
window.setTimeout(update, 60000);
},
success: function(output) {
output= jQuery.trim(output);
$('#userstatus').html(output);
window.setTimeout(update, 10000);
},
complete: function(){
}
});
<div id="userstatus"></div>
<input type="button" id="btnStart" value="start now">