ajax.data not being sent to the server with every request

ajax.data not being sent to the server with every request

martamarta Posts: 5Questions: 2Answers: 1

Hi and thanks for this great plugin!

We've been using DataTables in a way that might not have been intended. Instead of using DataTables search box, we have an advanced search in place. The search is done on the server side, passing a json string as ajax.data option (as per: https://datatables.net/reference/option/ajax.data):

data: function(d) {
    d.jsonQueryString = Run.jsonQueryString;
}

That string is passed to the server as an added parameter to all the parameters sent by DataTables, the results returned from the database and the DataTable correctly drawn.

But the json string is not passed to the server when doing pagination or sorting. So basically, the search returns a completely different set of results when clicking on the next page or trying to sort a column.

Is there any way to tell DataTables to use the data parameter with every request?

Let me know if you need more details, thanks a lot,
Marta

This question has an accepted answers - jump to answer

Answers

  • martamarta Posts: 5Questions: 2Answers: 1

    In fact, it seems that the jsonQueryString IS present in the parameter list sent to the server but it's set to "". So it might be my doing. Please disregard the question for now.

  • martamarta Posts: 5Questions: 2Answers: 1
    edited May 2016 Answer ✓

    Yes, definitely my doing. It was being reset somewhere in the code, not to collide with the default DataTables search box (while we still had it). Please disregard, works fine.

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Thanks for the updates - good to hear you've got it working!

    Allan

  • martamarta Posts: 5Questions: 2Answers: 1

    Thanks again for such a great plugin!

This discussion has been closed.