Datatable Ajax Filters

This article is written by Nitin, it explains how to use datatable ajax calls to load data for all its filters, pagination, sorting, search etc operations.


Create a table to initialize datatable.

 jQuery for datatable



  1. Initialize the table::: $('#demo).DataTable({});
  2. Set parameter “bProcessing“: true
  3. Set parameter “bServerSide“: true
  4. "oLanguage": { "sSearch": "", "sProcessing": "", "sZeroRecords": "" } 
  5. This parameter specifies the texts to be displayed.sSearch is used to set label for search boxsProcessing is used to set text displayed while processing any requestsZeroRecords is used to set text displayed when no results are found
  6. sAjaxSource::: Specify your ajax action url and name here.
  7. fnStateLoadParams::: Callback which allows modification of the saved state prior to loading that state. This callback is called when the table is loading state from the stored data, but prior to the settings object being modified by the saved state.
  8. fnServerParams::: This parameter is used to send all filter values to the server i.e. the ajax callback function.
    aoData.push( { “name”: “para_name”, “value”: “your_filter_values” } );para_name:::Specify the name to the parameters passed to the ajax callback function. This is used to get the value in the callback function.your_filter_values :::

    Parameter values that are to be passed to the ajax callback function. Value should be sent in JSON string format using JSON.stringify.

    To apply filter for individual filter elements selected and sending a ajax call use below lines. This line will set your selected value as a filter parameter a make an ajax call.


  9. This parameter allows you to override the default function which obtains the data from the server ($.getJSON) so you can do something more suitable for your application.

Ajax callback function