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
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
Excellent article...thanks anjana....
ReplyDeleteExcellent article...thanks anjana....
ReplyDelete