我有一个调用异步函数的函数。我的示例使用 ajax,但它实际上是异步的。
我正在尝试在 ajax 调用的成功中添加其他信息。
发生的顺序:
-my 函数被调用,参数是 $.ajax 调用。
-我的函数需要在 $.ajax.success 调用中添加 1 行代码
我的代码如下所示:
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
}
示例调用:
var settings = "";//settings of the ajax call.
myFunct(settings, function(x){ $.ajax(x);});