I am using jQuery Ajax API to handle my CRUD operations. I encounter the situation that I want to call the server using AJAX but do not want to handle the result with a callback function. Is there any way to handle the result without using callback functions.
There is sample code describes what I want.
if (ConfirmUserName(userName)) {
return "User Already Exist";
}
else {
return true;
}
The function used validates userName. Please note SendRequest method sends synchronous AJAX call to server.
function ConfirmUserName(userName) {
var validate = false;
SendRequest("/ClientUser/ValidateUserName", { ClientUserName: userName }, null, function (returnedData) {
validate = returnedData;
}, function () { }, null);
return validate;
}
If you are not expecting any output results from the Ajax request, you can simply ignore the
successattribute. However, this will have its own implications.