Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page Loader with jQuery

Tags:

jquery

What Im looking to do is something called 'loader' using jQuery.

Basically on site after choosing one option site will search database and will return matching results. All that is happening without refreshing the page.

Im looking to add "loader" - image that will appear while site is loading data from database and don't really know where to start.

Can someone please give me some clues, maybe plug ins or just refer me to some sites that have the solution?

Regards

like image 453
Dom Avatar asked May 09 '26 17:05

Dom


1 Answers

Just put an image with a loading indicator image somewhere on the site:

<img src="loader.gif" alt="" style="display:none" id="loader-indicator" />

Then use this javascript to show this right before the Ajax call fire's, then hide it again after it is finished.

$('#loader-indicator').show();
$.ajax({
    url:'ma/url',
    success: function(){
        $('#loader-indicator').hide();
    },
    error: function(){
        $('#loader-indicator').hide();
    }
});

If you need loading indicator images, I'd try http://www.ajaxload.info/. But it seems to be temporary unavailable.

like image 160
Znarkus Avatar answered May 12 '26 08:05

Znarkus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!