您可以參考您的演示下面的示例代碼。
$(document).ready(function() {
commonGateWay(/Get,"load URL","",loadTableDataSuccess);
$(document).on("click","#update",function(event){
//insertTable request
commonGateWay(/Post,"insert URL","",insertTableDataSuccess);
});
});
function loadTableDataSuccess(data){
//construct your table rows here
}
function insertTableDataSuccess(data){
//again call load table req from here
commonGateWay(/Get,"test URL","",loadTableDataSuccess);
}
//Method to initiate AJAX request
function commonGateWay(type, url, data, callback) {
$.ajax({
type: type,
url: url,
data: data,
success: function (data) {
callback(data);
}
});
}
來源
2017-02-24 05:45:14
SRI