php - Why does this function return zero? -


i have function triggered via jquery ajax.

within function, stop via return. example:

if ($processed_total < 3) {      echo 'post approved. ';      return; } 

the problem output be:

post approved. 0

note 0 @ end. why there? doing wrong?

edit:

here js used calling function:

jquery('.voteapproveform').submit(ajaxsubmit_voteapproveform);  function ajaxsubmit_voteapproveform(){      var voteapproveform = jquery(this).serialize();      jquery(this).parent().fadeout(); // hide approve , reject button prevent further voting      jquery.ajax({         type:"post",         url: siteparameters.site_url+"/wp-admin/admin-ajax.php",         data: voteapproveform,         context: this,         success:function(data){             jquery(this).fadeout(); // hide approve box on submit             jquery(this).parent().next().html(data); // empty div .modboxfeedback show returned data          }     });      return false; } 

return returns program control calling module. execution resumes @ statement following called module's invocation.

why function return zero?

if called within function, return statement ends execution of current function. not rest of other scripts or function.

for command line scripts, return statement not return status os!

instead, must use exit()

please refer docs also check example


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -