Jquery Datatable not working when call through Ajax -


i using jquery datatable display table values, fetching values ajax, normal table displaying,jquery datatable not supporting. if without ajax jquery datatable works fine, please me doing wrong.

   <script> $(document).ready(function() {     showmodal();     $('#example').datatable( {         "pagingtype": "full_numbers",         "searching": false     } ); } ); function showmodal(){ $.ajax({     url : "<c:url value='/endtoendservlet' />",     data : {     },     type : "get",     success : function(data, textstatus, jqxhr) {     console.log("enter json");     var table =' <table id="example" class="table table-striped " width="100%"> <thead>';         table +=' <tr class="success">';         table +='<th>sender</th>';         table +='<th>recipient</th>';         table +='<th>mail server</th>';         table +='<th>arrival time</th>';         table +='</tr>';         table +='</thead>';     for(var i=0;i<data.u.length;i++)     {     table += '<tbody><tr><td>'+data.u[i].sender+'</td><td>'+data.u[i].receiver+'</td><td>'+     data.u[i].mail_server+'</td><td>'     +data.u[i].arrival_time+'</td></tr>';     }     table += '<tbody>';         table +='</table>';         $("#resp1").html(table);                                         } }); } </script> </div> <div id="resp1"></div> 

when construct datatable

<script> $(document).ready(function() {     showmodal(); });  function showmodal(){     $.ajax({         url: "<c:url value='/endtoendservlet' />",         data: {         },         type: "get",         success: function (data, textstatus, jqxhr) {             console.log("enter json");             var table = ' <table id="example" class="table table-striped " width="100%"> <thead>';             table += ' <tr class="success">';             table += '<th>sender</th>';             table += '<th>recipient</th>';             table += '<th>mail server</th>';             table += '<th>arrival time</th>';             table += '</tr>';             table += '</thead>';             (var = 0; < data.u.length; i++) {                 table += '<tbody><tr><td>' + data.u[i].sender + '</td><td>' + data.u[i].receiver + '</td><td>' +                     data.u[i].mail_server + '</td><td>'                     + data.u[i].arrival_time + '</td></tr>';             }             table += '<tbody>';             table += '</table>';             $("#resp1").html(table);              $('#example').datatable({                 "pagingtype": "full_numbers",                 "searching": false             });         }     }); } 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -