javascript - How to show "Loading..." when i refresh the table with new parameters in Datatable Jquery? -
i want refresh datatable when choose new parameter send database query it. done it, how show "loading.." when refresh datatable loaded @ first time :
this script
<script type="text/javascript"> $(document).ready(function() { var otable = $('#tabelspta').datatable({ "processing": true "deferrender": false, "footercallback": function (tfoot, data, start, end, display) { var api = this.api(); var intval = function ( ) { return typeof === 'string' ? i.replace(/[\$,]/g, '')*1 : typeof === 'number' ? : 0; }; var p = api.column(10).data().reduce(function (c, d) { //mengatur penjumlahan total akhir di kolom ke-4 (kolom total) return parsefloat(c) + parsefloat(d); }, 0) $(api.column(10).footer()).html(p); //mengatur letak hasil total dari var p (diletakan di footer kolem ke-4) nb:kolom mulai dar index ke-0 // $("#total").val(p); }, ajax : { url: 'database.php', datatype: 'json', data : { 'name' : 'ia045'}, type : 'post', success: function(s){ console.log(s); console.log("cek data"); otable.fncleartable(); for(var = 0; < s.length; i++) { otable.fnadddata([ s[i][0], //nospta // s[i][1], //tglberlaku s[i][2], //noregisterinduk s[i][3], //namapetani s[i][4], //tglgawang s[i][5], //tglbruto s[i][6], //tglgiling s[i][7], //tgltarra parsefloat(s[i][8]).tofixed(0), //netto s[i][9], //rafraksi parsefloat(s[i][10]).tofixed(0), //potongan parsefloat(s[i][11]).tofixed(0), //netto ]); } // end }, error: function(e){ console.log(e.responsetext); } } }); $('#tmbltgl').on('click',function(){ $('#otable').datatable().clear(); var tgl = $('#mytext').val(); var user = $(this).attr('id'); if(user != '') { $.ajax({ url: 'database.php', datatype: 'json', data : {'tgl' : tgl, 'name' : 'ia045'}, type : 'post', success: function(s){ console.log(s); console.log("cek data"); otable.fncleartable(); for(var = 0; < s.length; i++) { otable.fnadddata([ s[i][0], //nospta // s[i][1], //tglberlaku s[i][2], //noregisterinduk s[i][3], //namapetani s[i][4], //tglgawang s[i][5], //tglbruto s[i][6], //tglgiling s[i][7], //tgltarra parsefloat(s[i][8]).tofixed(0), //netto s[i][9], //rafraksi parsefloat(s[i][10]).tofixed(0), //potongan parsefloat(s[i][11]).tofixed(0), //netto ]); } // end }, error: function(e){ console.log(e.responsetext); } }); } }); }); </script>
i add "processing": true, didn't work refresh data new parameter. how can that?
Comments
Post a Comment