I have a function that calls an async function. My examples use ajax, but it is really anything that is async.
I am trying to add additiional information in the success of the ajax call.
Order of what occurs:
-my function is called with a param being an $.ajax call.
-my function needs to add 1 line of code to the $.ajax.success call
my code is something like the following:
function myFunct(settings, callback){
if(!callback)return;
var x = 100;
//here is where i have issues, as i want
//to be able to adjust the success function
// to also have 1 line of code, a decrementer.
//I want to do something like settings.success = "x--;" + settings.success;
callback(settings);
//I also wasnt sure if you could wrap 'callback'
//with a success function when the inner success function executes
}
sample call:
var settings = "";//settings of the ajax call.
myFunct(settings, function(x){ $.ajax(x);});
If you make sure that callback always returns a promise object, you can use
.done()Just to be sure,
var x = 100is just an example right? as it stands now, it would go out of scope and is pointless.