大家好!
我有这样的ajax()电话:
$.ajax({
type: "post",
url: "whatever.php",
data: {
theData: "moo moo"
},
success: function(data) {
console.log(data);
}
});
Run Code Online (Sandbox Code Playgroud)
是否可以将其包装在自定义函数中但保留回调?
就像是:
function customAjax(u, d, theCallbackStuff) {
$.ajax({
type: "post",
url: u,
data: d,
success: function(data) {
//RUN theCallbackStuff
}
});
}
Run Code Online (Sandbox Code Playgroud)
theCallbackStuff 将是这样的:
var m = 1;
var n = 2;
alert(m + n + data);
Run Code Online (Sandbox Code Playgroud)