jQuery recursive function error -


i trying make following recursive function work keep receiving 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 receiving is: checkstatus(jobid) undefined

everything seems working should, firebug throwing warning. function repeating itself, posting jobid , receiving "processing" php script.

i had similar script using used settimeout() recursive not figure out how pass jobid along calling function (errors).

any ideas? thanks!

just remove .delay() , you'll rid of error. should use settimeout instead.

var checkstatus = function (jobid) {     $.ajax({         type: 'post',         url: '/admin/process/check-encode-status.php',         data: {             jobid: jobid         },         success: function (data) {             if (data == 'processing') {                 settimeout(function() { // <-- send anonymous function                     checkstatus(jobid); // <--    calls checkstatus                 }, 2000);             } else {                 $("#videooutput").html(data);             }         }     }); }; 

this because checkstatus() doesn't return explicitly, you're trying call .delay() on undefined.


Comments

Popular posts from this blog

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

apache - Add omitted ? to URLs -

php - How can I stop spam on my custom forum/blog? -