return true or false for main function from sub function

return true or false for main function from sub function

Dear All

I am, using following function to validate captcha

calling  checkcaptchafill.php to check whether entered value and session value
No issue in getting the valuse / result of this ajax correctly..this part is running well

the value of ajax call is stored in  $('#captcharesultdiv')

I want to check text stored in  of this DIV after (after comparing or validating the CAPTCHA entered

following ajax call does it well

  1. function formCheck(formobj){
  2.  $('#captcharesultdiv').text('');
  3.  var captcha=  $("input[name=captcha]").val();;
  4. alert(captcha);
  5. var url= "checkcaptchafill.php";
  6.      data = {
  7.   captcha: captcha
  8. }
  9.   
  10.     $('#captcharesultdiv').load(url,data, checkcaptchavalid )  ;
  11.  
  12. } ;
I tried

  1. $('#captcharesultdiv').load(url,data, checkcaptchavalid )  ;


function
checkcaptchavalid validates the CAPTCHA
however i want return false or true for main function :  formCheck

  1. function checkcaptchavalid()
  2. {
  3. var vld = $('#captcharesultdiv').text();
  4.  
  5.       alert("In Function="+vld);/* <-- getting correct value */
  6. if (vld==1)
  7. {
  8. return true; /*<-  should be for main function formCheck(formobj)*/
  9.  
  10.  
  11. }
  12. else
  13. {
  14.   $('#captchamessagediv').text('Pls Ente Correct CAPTCHA !!');
  15. $('#captchamessagediv').show();/* -> showing error workign correctly */
  16.  
  17. }