table.ajax.reload() is undefined

table.ajax.reload() is undefined

tshrovetshrove Posts: 4Questions: 3Answers: 0

When using the reload function on the ajax object within a table. table.ajax.reload(); I get that ajax is undefined. Does anyone know what the problem may be?

table.dataTable({
...,
ajax : 'url to ajax',
dataSrc : 'first_object_name',
....
});

table.ajax.reload(); ///// <<<<--------------- TypeError: cannot read property 'reload' of undefined 'ajax'

This question has an accepted answers - jump to answer

Answers

  • hungudgmhungudgm Posts: 3Questions: 1Answers: 1
    Answer ✓

    you should code: table.api().ajax.reload();

  • tshrovetshrove Posts: 4Questions: 3Answers: 0

    Thanks. That fixed it.

  • msypossmsyposs Posts: 1Questions: 0Answers: 0
    edited May 2014

    manual is confusing in its use of examples without explicit 'api' reference to the DT object

  • GlennGlenn Posts: 2Questions: 0Answers: 0

    I second @msyposs, the manual is very confusing. It leads you to believe that:

    `oTable.ajax.reload()`
    

    is valid. But it has to be:

    `oTable.api().ajax.reload()`
    
  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin

    Actually, the confusion here is over the difference between $().dataTable() which you are using and returns a jQuery object and the old DataTables API, and $().DataTable() which returns the new API instance.

    This is noted in the manual and FAQs - but I'm very interested to hear any suggestions you might have about how I can improve the documentation?

    Allan

  • redfroredfro Posts: 1Questions: 0Answers: 0
    edited September 2014

    Not reading the entire manual I missed that part as well, you should post both solutions, that would cut down on the confusion.

  • assuncaoassuncao Posts: 1Questions: 0Answers: 0

    I also got the same issue.

This discussion has been closed.