variable is not getting altered

variable is not getting altered

Hi Team,

On click of submit button , i am checking whether user entered id in one of the field is already choosen or not , if the user entered the id which is already choosen by other  user , i should not allow him to continue the submit button. so i have written following code but the UserExist function always returns true . Please help me out .

my servlet which i have mentioned in the url will return me the exisiting ids

my jquery code is below

$("button").click(function(){

if(UserExist("fldid")){
      alert("user name not exist")
}else
{
      alert("user exist");
}
})

function UserExit(fldid){

var el = $("#"+fldid);
var userEntry = el.val();
var processFurther = true;

$.ajax({
      type:'post',
      url:'checkdata',            ---- this is servlet which returns me existed user names
      data :'{}',
      success :function(result){
            
            resobj = JSON.parse(result)       ---> converting it into object and then looping it
            $.each(resobj,function(idx,val){

                  if(userEntry  == idx){
                  
                        processFurther  = false;       --> in my case values is getting matched and this field is                                                                          becoming false but when i return this field it is giving always true
                        return false            --> once the value is matched i am trying to exit the each loop

                  }
            });
      
      }
})
 return processFurther; ----> this value is always returning true please help me out where i am doing wrong
}

Thanks & Regards
Sai krishna