how to refresh a jquery Datatable after an operation ?

how to refresh a jquery Datatable after an operation ?


Hi, I have a datatable, the first column show agencies assigned to this row, in another column I have a button that when clicked show a form to assign new agencies to this row, everything work well, but for the new agencies added I have to refresh the page to see them, is there any way to add them as soon as I click the button "Assign" ?

here is an image showing what I am talking about :

http://s18.postimg.org/9xtvp7w6x/rr_Agency.png

Thanks.




  1. $("#divPopUp").dialog({
  2.         resizable: true,
  3.         autoOpen: false,
  4.         height: 500,
  5.         width: 550,
  6.         modal: true,
  7.         buttons: {
  8.             "Assign": function () {
  9.                   var agenciesId = $(this).find(":checkbox:checked").map(function () {
  10.                     return this.value;
  11.                 }).get();
  12.                  //alert("agenciesId :" + agenciesId);
  13.                  var ruleIDd = $("#divPopUp").data('param_1');
  14.                  $.ajax({
  15.                 url: 'assignRenameRuleToAgency.do',
  16.                 data: {"agenciesId": agenciesId,"ruleId":ruleIDd },
  17.                 success: function(response) {
  18.                    toastr.success(response.message);
  19.                 }
  20.             }) ;        
  21.                   oTable.draw(); 
  22.                 $(this).dialog("close");
  23.             },
  24.             Cancel: function () {
  25.                 $(this).dialog("close");
  26.             }
  27.         },
  28.         close: function () {
  29.             $(this).find(":checkbox").removeAttr('checked');
  30.             $(this).dialog("close");
  31.         }
  32.     });