Skip to content

Instantly share code, notes, and snippets.

@snobu
Created November 29, 2017 09:37
Show Gist options
  • Select an option

  • Save snobu/7c89efb38fcd2bcdb5867d15e87f28fe to your computer and use it in GitHub Desktop.

Select an option

Save snobu/7c89efb38fcd2bcdb5867d15e87f28fe to your computer and use it in GitHub Desktop.
Show spinner on ajax request (jQuery)
$.ajax({
url: "destination url",
success: ...,
error: ...,
// shows the loader element before sending.
beforeSend: function () {
$("#imgSpinner1").show();
},
// hides the loader after completion of request, whether successfull or failor.
complete: function () {
$("#imgSpinner1").hide();
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment