javascript - Hide "No data available in table" message when data is present -


this table , data list using json , populate table,

<table id="tblclaimsearch" class="display responsive nowrap" cellspacing="0" width="100%">     <thead>        <tr>           <th><input type="checkbox" id="chkboxclaimheader" name="chkboxclaimheader" value="false"></th>           <th>claim #</th>           <th>client name</th>           <th>amount</th>           <th>deduction</th>           <th>type</th>           <th>status</th>        </tr>     </thead>     <tbody>                            </tbody>  </table>  

my jquery has json result, result , append rows table body based on data,

$(document).ready(function () { $.ajax({             url: '@url.action("claimresulttest", "claims")',             data: { seacrhclaimnumber: claimnumbertobesearched },             type: 'post',             success: function (data) {                    var dataclaims = data.claims;//this has complete list                    (i = 0; < dataclaims.length; i++) {                     alert(dataclaims[i].claimnumber);                     $("#tblclaimsearch").find('tbody')                             .append($('<tr>')                             .append($('<td><input type="checkbox">'))                             .append($('<td>').text(dataclaims[i].claimnumber))                             .append($('<td>').text(dataclaims[i].client))                             .append($('<td>').text(dataclaims[i].amount))                             .append($('<td>').text(dataclaims[i].deduction))                             .append($('<td>').text(dataclaims[i].type))                             .append($('<td>').text(dataclaims[i].status))                                 )                      }                   }               });         }); 

the problem when there no data, have row displaying "no data available in table"..and when there data appended still have first row "no data available in table"..how hide message row when new rows data have been added??and secondly though have 16 entries still shows "showing 0 of 0 entries"?.what doing wrong?..

try this:-

$(document).ready(function () {  $.ajax({         url: '@url.action("claimresulttest", "claims")',         data: { seacrhclaimnumber: claimnumbertobesearched },         type: 'post',         success: function (data) {                    $("#tblclaimsearch").find('tbody').empty(); //add line                 var dataclaims = data.claims;//this has complete list                (i = 0; < dataclaims.length; i++) {                 alert(dataclaims[i].claimnumber);                 $("#tblclaimsearch").find('tbody')                         .append($('<tr>')                         .append($('<td><input type="checkbox">'))                         .append($('<td>').text(dataclaims[i].claimnumber))                         .append($('<td>').text(dataclaims[i].client))                         .append($('<td>').text(dataclaims[i].amount))                         .append($('<td>').text(dataclaims[i].deduction))                         .append($('<td>').text(dataclaims[i].type))                         .append($('<td>').text(dataclaims[i].status))                             )                  }               }           });     }); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -