javascript - show page loading icon while loading table -
i have table in html file <table id="table" class="table table-striped">
, call gettabledata
function , dynamically update table using jquery
$(document).ready(function(){ gettable(); $(document).ajaxstop(function () { ... });
i using ajaxstop run next functions after table rendered.
function gettable(){ $.get("api/table", function(data){ settable(data); } }
where settable
renders table. how can show loading icon while table data fetched?
with jquery can send success
callback on $.get()
(so when data received) , handle loading css class:
function gettable(){ // before call server add loading style $('#table').addclass('is-loading') $.get("api/table", function(data){ // after receiving data remove loading style $('#table').removeclass('is-loading') settable(data); } }
Comments
Post a Comment