I am trying to make the following recursive function work but keep receiving an error (following code):
var checkStatus = function(jobID) {
$.ajax({
type: 'post',
url: '/admin/process/check-encode-status.php',
data: {jobID: jobID},
success: function(data) {
if (data == 'processing') {
checkStatus(jobID).delay(2000);
} else {
$("#videoOutput").html(data);
}
}
});
};
The error I am receiving is: checkStatus(jobID) is undefined
Everything seems to be working as it should, Firebug is just throwing this warning. The function is repeating itself, posting the jobID and receiving “processing” from the PHP script.
I had a similar script that I was using that used setTimeout() to be recursive but I could not figure out how to pass the jobID along with calling the function (errors).
Any ideas? Thanks!
Just remove the
.delay()and you’ll get rid of the error. You should usesetTimeoutinstead.This is because
checkStatus()doesn’t return anything explicitly, so you’re trying to call.delay()onundefined.