Implementation of bootstrap jquery dataTable asynchronous ajax refreshing table data, jquerydatatable

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.