data.json

data.json

kkambikkambi Posts: 2Questions: 1Answers: 0

Hi There, I used the below ajax function to reload my table every 3 second to show latest updated data from my database; My code is as follows but it does not work. I dont know where is data.json coming from. please can someone help me. My table id is ****getdata****.

var table = $('#getdata').DataTable( { ajax: "data.json" } ); setInterval( function () { table.ajax.reload( null, false ); // user paging is not reset on reload }, 3000 );

Answers

  • allanallan Posts: 63,352Questions: 1Answers: 10,443 Site admin

    dont know where is data.json coming from

    That ajax option just points to wherever your data is. So if data.json is where your JSON data that you want to update is, then that is where you would point it. If it is something else, use a different URL.

    Allan

  • kkambikkambi Posts: 2Questions: 1Answers: 0

    Now i have replaced data.json with my page containing the table as below but still not refresh table. Am i missing something here? Please help me accomplish this. thank.

    var table = $('#getdata').DataTable( {
    ajax: "refreshtable.php"
    } );
    setInterval( function () {
    table.ajax.reload( null, false );
    }, 3000 );

  • allanallan Posts: 63,352Questions: 1Answers: 10,443 Site admin

    If you post a link to the page showing the issue, I'd be happy to take a looks and help debug it.

    Allan

This discussion has been closed.