i have a custom jQuery function with callbacks, in one of them i want to do a server-side check before some event is triggered.(我有一个带有回调的自定义jQuery函数,在其中之一中,我想在触发某些事件之前进行服务器端检查。)
Something like this:(像这样:)
var object = $('#object').customFunction({
onSomeEvent: function (someData) {
$.ajax({
...
...
success: function(data) {
if (data == ok) {
return true;
} else {
return false; *****
}
}
})
},
})
**** I want this "return false;"(****我想要这个“返回假”;) to be the return of "onSomeEvent".(是“ onSomeEvent”的返回。) I know i can make the ajax call async false, save the response data in a variable, check it after the ajax and return the false then, but i really would like to avoid the async false.(我知道我可以使ajax调用async为false,将响应数据保存在变量中,在ajax之后检查它,然后返回false,但是我真的很想避免async false。)
I really dont know what to try, everything i google is putting the ajax async on false.(我真的不知道该怎么尝试,我将google的所有内容都将ajax异步设置为false。)
Thanks in advance for your help!(在此先感谢您的帮助!)
ask by Emepese translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…