0

i have muliple tables, but i try only to refresh one of them not the whole page. There is running a sql so i want to have always real data I searched but could not find any think which was really useful. Any idea how to solve this issue ?

    $(document).ready( function() {
    $('.test').load();
     refresh ();
     });
     function refresh ()
     {
            setInterval ( function() {
            $('.test').fadeOut('slow').load().fadeIn ('slow');
            refresh();
          }, 30000);
    }
            <table class="test">
            <tbody>
            <tr><td>test- sql data comes here</td></tr>
      </tbody>          
      </table>
      
      <table class="test2">
            <tbody>
            <tr><td>test2</td></tr>
      </tbody>          
      </table>


      <table class="test3">
            <tbody>
            <tr><td>test3</td></tr>
      </tbody>          
      </table>

      
James
  • 132
  • 12
  • Just add rows to your table when new data comes in - no need to refresh the page. You can run the function that queries for data repeatedly without refreshing the page. – Adam Neuwirth Jul 15 '20 at 19:08
  • 2
    Since you are using `jquery` I would research `ajax`. I would add that as answer but it requires server side processing which you don't have here so there would be more to figure out for you. AJAX allows you to send data to a server and have it respond with the appropriate content, that content you could append to your table. There are other methods but AJAX is the simplest to wrap your head around. – imvain2 Jul 15 '20 at 19:12
  • hi @AdamNeuwirth thx for the reply! this is based on a select sql. if the page don't get load you will now see the new data.... so can you tell me more... what excatly you meant. thank you – James Jul 15 '20 at 19:12
  • @imvain2, it should not be ajax can be something simple... but i just don't find the right balance.. any idea how to make it simple/easier ? thx. – James Jul 15 '20 at 19:13
  • I just noticed you are using `load` in your code, which is a shorthand for a larger `ajax` function but you aren't actually loading any remote content. – imvain2 Jul 15 '20 at 19:29
  • because it doesn't work also if i put an url .... do you may know better solution ? reload only the table content --> like i will refresh the page – James Jul 15 '20 at 19:43
  • Have a look at this question: https://stackoverflow.com/questions/17886578/refresh-part-of-page-div – Rylee Jul 16 '20 at 00:53

0 Answers0