简体   繁体   English

当我单击下一个或上一个按钮时,数据表显示旧值。

[英]datatable is displaying old value when i click next or previous button.

im using jquery datatable for displaying data based on user search using ajax. 即时通讯使用jquery数据表基于使用ajax的用户搜索显示数据。 the datatable is not refreshing. 数据表未刷新。 it is displaying first time loaded value when i click next or previous button. 当我单击下一个或上一个按钮时,它显示的是第一次加载的值。

function searchCustomer() {

 var frm = $("#customerDetailSearchForm").serializeObject();
 $("#tbl_contact_search_result").hide();

 $.ajax({ 
 type: 'POST', 
 url: restContextPath + '/IONSWeb/rest/order/searchContact', 
 data: JSON.stringify(frm),
 dataType: 'json',
 contentType: "application/json; charset=utf-8",
 success: function(data, status, xhr) {             
         $("#tbl_contact_search_result tbody").empty();
     $.each(data.body, function(i, item) {                 
         var checkBox = item.actionString;
         var dataTableBodyHTML = '<tr><td>'+ checkBox + '</td><td>'+ item.name + '</td><td>'+ item.street +'</td><td>' + item.city + '</td><td>'+ item.state + '</td><td>' + item.phone +'</td></tr>';

         $("#tbl_contact_search_result tbody").append(dataTableBodyHTML);            
         $("#tbl_contact_search_result").show();
     });        
         var dataTable = $('#tbl_contact_search_result').DataTable();

        },
        error: function(jqXhr, textStatus, errorMessage) {               
              $('.ErrorMsg').html('<h5>An error has occurred</h5>');
           }
        });
  }

Just disable the ajax caching feature. 只需禁用ajax缓存功能。 The default value is true . 默认值为true So, you have to set it as false. 因此,您必须将其设置为false。 (cache: false) (缓存:false)

function searchCustomer() {

 var frm = $("#customerDetailSearchForm").serializeObject();
 $("#tbl_contact_search_result").hide();

 $.ajax({ 
 type: 'POST', 
 url: restContextPath + '/IONSWeb/rest/order/searchContact', 
 data: JSON.stringify(frm),
 dataType: 'json',
 cache: false,
 contentType: "application/json; charset=utf-8",
 success: function(data, status, xhr) {             
         $("#tbl_contact_search_result tbody").empty();
     $.each(data.body, function(i, item) {                 
         var checkBox = item.actionString;
         var dataTableBodyHTML = '<tr><td>'+ checkBox + '</td><td>'+ item.name + '</td><td>'+ item.street +'</td><td>' + item.city + '</td><td>'+ item.state + '</td><td>' + item.phone +'</td></tr>';

         $("#tbl_contact_search_result tbody").append(dataTableBodyHTML);            
         $("#tbl_contact_search_result").show();
     });        
         var dataTable = $('#tbl_contact_search_result').DataTable();

        },
        error: function(jqXhr, textStatus, errorMessage) {               
              $('.ErrorMsg').html('<h5>An error has occurred</h5>');
           }
        });
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击按钮时,图形和增量不显示。 交叉原点错误 - The figure and the increment is not displaying when I click the button. Cross origin error 单击按钮时,我想使用 JavaScript 插入文本。 但是 ```.value()``` 似乎不起作用 - I want to insert text using JavaScript when I click on button. But ```.value()``` doesn't seems to work 我可以让下一个按钮工作,但不能让上一个按钮工作。 我究竟做错了什么? - I can get the next button to work but not the previous button. What am I doing wrong? 当我在 VueJS 中单击下一个或上一个按钮时显示一个列表 - Display a list when i click next or previous button in VueJS 具有“下一步”按钮的wordpress网站上的iframe。 我需要自动点击 - iframe on a wordpress site that has a “next” button. I need to auto click that or something 单击下一个/上一个按钮时,如何将活动类更改为LI元素? - How do I change the active class to the LI element when I click next/previous button? 单击“上一张/下一张”照片按钮时,离开并重新进入照片库会使您浏览的照片数量增加一倍。 知道为什么吗? - Leaving and re-entering a photo gallery doubles the amount of pictures you go through whenever you click the Previous/Next photo button. Any idea why? 当我点击下一个按钮时,上一个问题必须用反向 animation 删除,下一个问题必须显示输入效果 animation - When i click on next button, the previous question must be remove with reverse animation & next question must be show with typing effect animation 单击 slider 下一个和上一个按钮我得到 $curr[action] is not a function - On click slider next and previous button i get $curr[action] is not a function 当我单击特定的“addToBasket”按钮时,我不想更改所有“addToBasket”按钮。 只有点击的按钮应该改变 - I do not want all the "addToBasket" buttons to change when i click on a specefic "addToBasket" button. Only the clicked button should change
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM