I have a set of time out functions inside one function
function myFunction()
{
var data;
setTimeout(function(){
$.ajax({
//My Ajax Junk
success: function(data) {
var data = data.trim();
// I want to be able to use this later on.
}
}):
}, 6000);
setTimeout(function(){
var shipping = 'f_name='+f_name+data;
// Append data from previous call to shipping
}, 12000);
}
I'm wanting to retrieve the data from the ajax success function and then use it inside the next timeout function by appending it to the shipping variable. I have declared the variable data outside of all the functions and then tried to add the success data to it. When I alert out the shipping variable it doesn't show anything extra (what the data should be adding).
The data is returning because I can see it in Google Chromes Network Tab.
How can I set a variable to be used throughout the entire function!?!?!?!?
Thank you in advance.
Also, the success function is returning prior to the call for the data to be added because of the timeout functions. I played with them to be set right for this instance.
Aucun commentaire:
Enregistrer un commentaire