完成Bserverside Ajax函数后如何调用另一个函数,
..................
"fnServerData" : function( sSource, aoData,fnCallback) {
$.ajax({
"dataType" : 'json',
"type" : "GET",
"url" : sSource,
"data" : aoData,
"success" : fnCallback
});
};
我试过了
.........
"fnServerData" : function( sSource, aoData,fnCallback) {
$.ajax({
"dataType" : 'json',
"type" : "GET",
"url" : sSource,
"data" : aoData,
"success" : fnCallback
});
alertFunction();
};
function alertFunction(){
alert('hi');
}
,但它将在完成之前调用。
最佳答案
你可以用.always()
链接它:
$.ajax({
"dataType" : 'json',
"type" : "GET",
"url" : sSource,
"data" : aoData,
"success" : fnCallback
}).always(function(){ // add it here.
alertFunction();
});
或者您可以添加"complete"
:
$.ajax({
"dataType" : 'json',
"type" : "GET",
"url" : sSource,
"data" : aoData,
"success" : fnCallback,
"complete": alertFunction
});
关于javascript - 完成Bserverside Ajax函数后如何调用另一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34130355/