Skip to content
Advertisement

After button click, show spinner icon on button while click event in progress

I’m trying to show spinner on button while loading on submit, I have seen a couple of implementations and tried in my application but its not working. Here is the fiddle which I am trying to describe. I want to mention one other thing that this HTML is on my sidebar and being added through javascript on ajax call

JavaScript
JavaScript
JavaScript

Advertisement

Answer

I made some changes (changed the icon and edited the CSS) in you code to be easier to test: http://jsfiddle.net/q1d06npq/4/

Instead of $.ajax().done() the best option in you case is to use the $.ajax().always() that is executed even if the ajax fails.

The code $(this) inside the callback function will not point to the button, to solve that you can use something like this: var elem = $(event.currentTarget);

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement