fnReloadAjax: incorrect number of parameters

fnReloadAjax: incorrect number of parameters

getzgetz Posts: 2Questions: 0Answers: 0
edited September 2013 in Plug-ins
Hi!

I'm using datatables 1.9.4 with ajax call and the plug-ins fnReloadAjax.

I'm front of a problem i cannot explain:
I want to launch a callback function after the ajax reload.
The function fnReloadAjax is :
[code]$.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw ) [/code]

Ok, so i call it like this:

[code]var table = $("#myTable").dataTable();
table.fnReloadAjax(table.oSettings, null, myCallbackFunction); [/code]

But when i debug into the fnReloadAjax function, fnCallback is null! The function "myCallbackFunction" is passed in the argument bStandingRedraw!

The solution is to remove the sNewSource parameters when calling the function like this:

[code]var table = $("#myTable").dataTable();
table.fnReloadAjax(table.oSettings, myCallbackFunction); [/code]

It works fine now, but i can't understand why this is happening... Someone can explain me?

Thanks!

Replies

  • getzgetz Posts: 2Questions: 0Answers: 0
    Here is a jsBin:

    http://live.datatables.net/eqazet/4/edit#source

    My function callback doesn't alert here , I don't know why, but it's not the problem.
    Just follow the instruction I wrote in the html...
  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin
    The settings object is automatically added by DataTables - don't pass it in. So what you should use externally is:

    > fnReloadAjax function ( sNewSource, fnCallback, bStandingRedraw )

    This is noted at the top of the API plug-ins page:

    > Please note that DataTables will automatically pass the settings object as the first parameter. As such, you do not need to pass the settings object, which you will see if you look at the plug-in API's code.

    Allan
This discussion has been closed.