Is there a way to pass more data into a callback function in jQuery?(有没有办法将更多数据传递给jQuery中的回调函数?)
I have two functions and I want the callback to the $.post
, for example, to pass in both the resulting data of the AJAX call, as well as a few custom arguments(我有两个函数,我想要回调$.post
,例如,传入AJAX调用的结果数据,以及一些自定义参数)
function clicked() {
var myDiv = $("#my-div");
// ERROR: Says data not defined
$.post("someurl.php",someData,doSomething(data, myDiv),"json");
// ERROR: Would pass in myDiv as curData (wrong)
$.post("someurl.php",someData,doSomething(data, myDiv),"json");
}
function doSomething(curData, curDiv) {
}
I want to be able to pass in my own parameters to a callback, as well as the result returned from the AJAX call.(我希望能够将自己的参数传递给回调,以及从AJAX调用返回的结果。)
ask by atp translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…