Is this possible to return value from function which includes an ajax call after the call is executed? For example, in the example here, function1 and function2 both have ajax calls. I'm forced to specify async as false for both the requests as the value that is returned from the functions is setup in the success callback. Is there anyway to overcome this issue so that calls can still be asynchronous but the return values are fine?
$(document).ready(function(){
var abc = function1();
var xyz = function2();
});
function1()
{
var value = "";
$.ajax({
url: url,
async: false,
success: function(data) {
value = "value1";
}})
return value;
}
function2()
{
var value = "";
$.ajax({
url: url,
async: false,
success: function(data) {
value = "value2";
}})
return value;
}