Loader for html /php files using jquery
I have some html/php pages with large amount of data. It takes few more extra seconds to load from the server. Is there any way to show "loader animation" for html pages/php pages using jquery? After completely loading开发者_运维技巧 the html/php page, the "loader animation" should be hide.
Thanks in advance
Sure.
Attach some javascript to the pages load event to a) show the 'Loading' animation b) kick off an ajax call to load the data and then c) clear the animation once finished.
Its pretty standard stuff - any AJAX tutorial will give you enough.
You can use the AJAX functions as : ajaxStart() http://api.jquery.com/ajaxStart/ and ajaxStop() http://api.jquery.com/ajaxStop/
Simplest way :
You put a <div class="loader"></div>
in head which loaded everytime on everypage, then create a function :
function hideLoad(){$('.loader').hide();}
and put onload in body tag as :
<body onload="hideLoad()">
that allow div to be showed up untill everything has been loaded.
精彩评论