As Ryan said, you can't return a value directly, because the function returns
before the asynchronous AJAX method has completed.
You need to re-write your code to use a more asynchronous approach. For example:
function getname(a, b)
{
return $.ajax(...);
}
function validate(a)
{
return $.ajax(...);
}
function checken(a)
{
return $.ajax(...);
}
function callallfunctions()
{
var aval = document.getelementbyid('myval');
return getname(aval.value, 'abc')
.then(function(getnameResult){ return !!getnameResult.resultvalue ? validate('abc') : false; })
.then(function(validateResult){ return !!validateResult.resultvalue ? checken('def') : false; })
.then(function(checkenResult){ return !!checkenResult.resultvalue });
}
This uses jQuery's implementation of
JavaScript Promises[
^] to chain the asynchronous calls together.
Your calling code can then use the
.done()[
^] and
.fail()[
^] methods to register functions which will be called when all three methods have been completed, or when one of the methods fails.
callallfunctions()
.done(function(result){ alert(result); })
.fail(function(){ alert("Failed"); });