Imagine my JS script is the following :
function big_code() {
do_a_lot_of_stuff
$.ajax({
type: "post",
url : host + "/function1",
headers: {"content-type": "application/json"},
datatype: "json",
contentType: "application/json; charset=utf-8",
data: my_variables1 ,
success:function(){
$.ajax({
type: "post",
url : host + "/function2",
headers: {"content-type": "application/json"},
datatype: "json",
contentType: "application/json; charset=utf-8",
data: my_variables2,
success:function(data){ VARIABLES = SOMETHING })
}
})
return VARIABLES }
function other_bigfunction() {
VARIABLES = big_code()
do_something_else...
I succeeded to get the variable VARIABLES from big_code function by using async=false in ajax requests.
Of course it is unconvenient because all others functions stop working….
Have you an idea to obtain this variable in big_code() ONLY after ajax requests?
Thank you in advance