When i’m using this code it’s not activating the setTimeout on success return from jQuery
function waitForEvents(last_id){
$.ajax({
type: "GET",
url: "/functions/ajax.php?func=feed&old_msg_id="+last_id,
async: true, /* If set to non-async, browser shows page as "Loading.."*/
cache: false,
timeout:50000, /* Timeout in ms */
success: function(data){
var json = jQuery.parseJSON(data);
if(json !== 'null') {
$.each(json.earnings, function (index, value) {
$('#feed').append(value);
});
var old_msg_id = json['last_id'];
}
alert("working");
setTimeout('waitForEvents(last_id)',"1000");
},
error: function (XMLHttpRequest, textStatus, errorThrown){
alert("Error:" + textStatus + " (" + errorThrown + ")");
setTimeout('waitForEvents(last_id)',"15000");
},
});
};
Any idea why because it’s actually returning (data) so it’s processing the response just not activating the settimeout again
Your setTimeout method is not passing a function (apparently as a string is fine :/)