AiD
AiD

Reputation: 1007

Showing loader gif in datatables

I'm using datatables. My code is working fine. Now I want to add a loader image(gif). I don't know how to add this. Here is my datatable script .

$(document).ready(function() {
    var ref = $('#example').DataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": "mails",
        "columns": [
                    { "data": "from" },
                    { "data": "object" },
                    { "data": "created" }
                ]
    } );

} );

Upvotes: 2

Views: 10982

Answers (2)

eocavalcanti
eocavalcanti

Reputation: 78

You can simply put an image tag within the language option:

language: {
          processing: "<img src='img/loading.gif'>"
      }

Upvotes: 5

davidkonrad
davidkonrad

Reputation: 85558

You can use language.sLoadingRecords to show an ajaxload-gif, example :

...
language : {
  sLoadingRecords : '<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>'
},  
...

demo -> http://jsfiddle.net/acjngj30/

Upvotes: 5

Related Questions