Implementation of bootstrap jquery dataTable asynchronous ajax refreshing table data, jquerydatatable
Asynchronous request
Var postData = {"env_name": new_env_name, "env_url": new_env_url, "env_desc": new_env_desc}; $. ajax ({type: 'post', url: '/test_env_add/', data: postData, ype: 'json', success: function (data) {$ ('# table_test_env '). dataTable (). fnClearTable (); // clear the table $ ('# table_test_env '). dataTable (). fnAddData (packagingdatatabledata (data), true); // fl the table $ ("# modal-container-648308 "). modal ("hide") ;}, error: function (data) {alert ("failed to add ");}})
The data processing function packagingdatatabledata. The data. test_env_all returned by an asynchronous request must be in json format.
Function packagingdatatabledata (data) {var editHtml = '<button href = "# modal-container-648308" rel = "external nofollow" data-toggle = "modal" class = "btn-xs btn-info "onclick =" test_env_modify (this) "> <I class =" icon-edit bigger-120 "> </I> </button> <button href =" # modal-container-648300 "rel =" external nofollow "data-toggle =" modal "class =" btn-xs btn-danger "onclick =" test_env_delete (this) "> <I class =" icon-trash bigger-120 "> </I> </button> '; var a = []; // list var banddata = data for all row data. test_env_all; for (var key in banddata) {var tempObj = []; // list tempObj of a row of data. push (banddata [key]. id); tempObj. push (banddata [key]. name); tempObj. push (banddata [key]. url); tempObj. push (banddata [key]. desc); tempObj. push (editHtml);. push (tempObj);} return ;}
The above is the bootstrap jquery dataTable asynchronous ajax refresh table data introduced by xiaobian. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!