How to refresh updated table rows in div using ajax

时间:2015-05-24 20:22:48

标签: javascript jquery html ajax

I need your help in refreshing the div="table" which it has a table that is retrieving its rows from the database.

<div id="table">
    <h1 id="Requests">
        <table></table>
    </h1>
</div> 
<button id="refresh-btn">Refresh Table</button>

I tried to use the below jquery, however it is refreshing the div without picking up the updates from the database.

<script>
$(document).ready(function() {

   function RefreshTable() {
       $( "#table" ).load( "requests.html #table" );
   }

   $("#refresh-btn").on("click", RefreshTable);
});
</script>

1 个答案:

答案 0 :(得分:0)

Delete table

 <script>
  $(document).ready(function() {

   function RefreshTable() {
   table.innerHTML = '';
   $( "#table" ).load( "requests.html #table" );
   }

   $("#refresh-btn").on("click", RefreshTable);
});