Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS - Beyond the Basics CSS Animation Basics Keyframe Rules and Animation Properties

How to used to load time

Hi, im learning about css animations here and i want to know how can apply this loading bar appear on load time of a ajax request?

1 Answer

28,736 Points

I've already done it using the JQuery ajaxStart & ajaxStop methods (With font awesome for the loader).

As a quick example:


$(document).ajaxStart(function() {

$(document).ajaxStop(function(){ // Hide it once the ajax request is done.

$('nav li a').click(function(){ // when you click on the anchor, show the loader.

For the HTML as I wrote above, I simply used font awesome on my side. Here is the snippet.


    <div id="loadAjax">
        <i class="fa fa-spinner fa-xx fa-spin"></i>

Lastly don't forget to hide the loader with some css, as you simply want to show that one when there is an ajax request.



Hope it helps. You'll probably be able to adapt it with your css animation.

Awesome, i didn't know about that. Thanks.