您可以参考以下示例代码进行演示。
$(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);
}
});
}