How to redraw whole table?

How to redraw whole table?

SanZamoyskiSanZamoyski Posts: 12Questions: 2Answers: 0

Hi!

I'm using datatables to visualise some data fom mysql.
I create table with:

ajax": "js_data.php",

and create some additional <tr> with
var dt = api.rows({page:'current'}).data(); dt.each( function( group, i) { ... }

I've added
setInterval( function () { table.ajax.reload(); table.draw(); }, 10000 );
at the end of $(document).ready(function() {...})

but when i load my page and change something in the database, and wait 10 secs it logs me that it loads new ajax, but does not change anything on page.

Please help!

Answers

  • SanZamoyskiSanZamoyski Posts: 12Questions: 2Answers: 0

    Ok, the problem is that js receives 404 from server (while file exists and i can load it) it's becose of Wordpress... What can i do?

  • SanZamoyskiSanZamoyski Posts: 12Questions: 2Answers: 0

    So...

    I've found workaround - i made WP template WITHOUT anything, and just put there scripts to generate json data - it works!

    Almost...

    I've tried this: http://datatables.net/manual/tech-notes/1
    But no point, js data is correct according to everything (chrome console - there is nothing wrong with response, http://json.parser.online.fr/ and http://jsonlint.com/ validates).

    I have no idea what to do next...

    { "data": [ { "id": "33", "nazwisko": "Monika", "redakcja": "TV", "branza": "Ekonomiczna", "redaktor_uwagi": "Biznes", "redakcja_uwagi": "", "kontakt_uwagi": "tego", "maile": "m@r.pl; m.k@r.pl", "szukajka": "555 666 333, ; ", "status": "", "status_id": "7233", "telefony": [ { "tel_id": "37", "tel_num": "555 666 333", "tel_uw": "", "tel_s": "0", "tel_ns": "0" } ] }, { "id": "1433", "nazwisko": "Bartek", "redakcja": "Puls", "branza": "", "redaktor_uwagi": "", "redakcja_uwagi": "", "kontakt_uwagi": "", "maile": "b@b.pl", "szukajka": "22 333 44 55, ; ", "status": "", "status_id": "6868", "telefony": [ { "tel_id": "1309", "tel_num": "22 333 44 55", "tel_uw": "", "tel_s": "0", "tel_ns": "0" } ] } ] }

    There are much more records (about 1200)...

  • SanZamoyskiSanZamoyski Posts: 12Questions: 2Answers: 0

    Ofcorse i get 'Invalid JASON response'.
    Here is debug: http://debug.datatables.net/usiqos

    Regards and Good Night!

  • SanZamoyskiSanZamoyski Posts: 12Questions: 2Answers: 0

    According to this discussion: https://datatables.net/forums/discussion/24098/invalid-json-response-from-server-for-the-following-json-data
    i've rebuilt my scripts with usage of

    echo json_encode(array(array('column1key'=>'column1value','column2key'=>'column2value')));

    and it works fine now.

This discussion has been closed.