I am trying to call two different functions in a third function, but one by one. One function has an ajax call whose values are used in another function. it is step by step. I do not want to use it in another.
function f1()
{
return r1
}
function f2(r2)
{
}
function f3()
{
$.when(f1()).done(function(data){
f2(data)
});
}
I also tried with $ .when (). then (); but still useless.
Thanks in advance.
UPDATE: - Below is the answer for my Question based on the solution provided by @dreamweiver.
var json_data = '';
function f1()
{
$.ajax({
url: "test.php",
method: "POST",
async : false,
data: { },
success:function(data){
json_data = eval(data);
}
});
}
function f2(t)
{
console.log("values is "+t);
}
function f3()
{
$.when(f1()).done(function(){
f2(json_data);
});
}
Thank you all for your feedback.
source
share