I know this has been asked many times.I have a Javascript function that need return result from a async call.
function IsValid(callback){
$.ajax({
url:...
success:(function(data){
callback(data);
});
};
IsValid(function(data){
//process returned data
};
Also I can use promise to do similar job. However, what I need is IsValid function must return a bool value, not process the result directly.i.e, I need
if (IsValid())
//process
because IsValid function will be called in different function and the process is different on each caller function.
Any help will be appreciated. Thanks.