Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using a tag and with the help of jquery and event.preventDefault display data inside selector. but it is delay of data loading from database. so i want to display some loader during data fetching from database.
Posted

1 solution

Its simple all you have to do is just put an image and make it hide on page load like this..

HTML
<img id="loaderimg" src="/filepath/img.jpg" style="display:none;"></img>



And when your ajax starts to call you have to just show it

JavaScript
<script>
function a(){
//your function comes here to fetch data
$("#loaderimg").show()
//function to fetch data from DB

$("#loaderimg").hide()
}

</script>
 
Share this answer
 
Comments
Abhilask kumar 29-Nov-13 7:15am    
$('.load').click(function(event) {
$('#loaderimg').show("fast");
event.preventDefault();
$('#Data').load($(this).attr("href"));
$('#loaderimg').hide("slow");
});
html
<div id="Data" style="width:70%; float:left;">
<img id="loaderimg" src="css/images/footer-wonders.gif" style="display:none;"></img> </div>
November

Image display first time but after one click not display.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900