Capture AJAX response and assign to a variable using JQUERY

function checkforduplicateempname(){
 var message=true;
 /*Assigning AJAX response to a javascript variable*/
 var empId = $.ajax({
   url: 'checkforduplicateempname.relay',
   data: oMyForms,
   cache: false,
   contentType: false,
   processData: false,
   global: false,
   async:false,
   type: 'POST',
   success: function(data){
    return data;
       },error:function(){
    $("#empname").notify("Unable to check for duplicate title.","error");
       }
}).responseText; //end of ajax capturing the response
    if(empId!='0'){
    $("#empaname").notify("Duplicate Title.","error");
    message=false;
    }

return message;
}//end of function

Comments

Post a Comment

Popular posts from this blog

defining functions clojure

Integrating Struts2 with Spring Security using Custom Login Form