Add additional parameter to ajax request

Add additional parameter to ajax request

MausinoMausino Posts: 61Questions: 19Answers: 0

Link to test case:

https://datatables.net/examples/server_side/custom_vars.html
https://datatables.net/reference/option/ajax.data

Here are examples how to add extra parameters/extra http variables.

https://datatables.net/reference/api/ajax.params()
Here is example how i get the parameters which i am sending in ajax.

Will possilble somehow ??? to add new parameters to ajax call like

        var table = $('#example').DataTable( {
            ajax: "data.json",
            serverSide: true
        } );

        var visibleStatusOfIcon = 'true';

        table.on( 'xhr', function () {
            table.ajax.setParams(visibleStatusOfIcon);
        } );

the method/function setParams() is only my idea.... is the way how to add additional parameters to ajax call additionaly if in default ajax call i have parameters but i want add new one there from other place ???

Thank you :)

Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794
    Answer ✓

    Take a look at the preXhr for an example of setting parameters sent to the server. The xhr event fires when the response is received, too late to set parameters.

    Kevin

  • MausinoMausino Posts: 61Questions: 19Answers: 0

    @kthorngren thank you for reply. Now it's working as expected.

Sign In or Register to comment.