jQuery DataTables (legacy version) seems to send too many ajax calls to server when using search feature

So we are using datatables (1.9.4, legacy version) like this:

        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "/something.php",
        "fnServerParams": function ( aoData ) {
            aoData.push( { "name": "param", "value": <?=$_GET['id']?> });

What then happens is someone goes to use the search input and might type something like "hello world" -- as the user types, the dataTables plugin is then making 11 separate ajax calls to something.php, for "h" then "he" then "hel" ... and so forth.

I don't see any way referenced in the docs as to how to perhaps add a delay before making a server call, say, 1 second, or 1.5 seconds, of no typing, before the client sends the request.

I did however see mention here: http://legacy.datatables.net/release-datatables/examples/server_side/pipeline.html of concerns of overloading your server by sending a request for each "next" pagination action, for example, yet this concern seems even more worrisome as I've been finding.

Anyone else solve this problem? (And yes, we do need to optimize the server-side API calls but minimizing those from dataTables would be also very helpful.)

Answers 1

Related Articles