Skip to content

Instantly share code, notes, and snippets.

@iirving
Created August 16, 2010 19:03
Show Gist options
  • Save iirving/527536 to your computer and use it in GitHub Desktop.
Save iirving/527536 to your computer and use it in GitHub Desktop.
as per Adding a “loading” image to (just about) any form on submit, with jQquery
<script language="javascript" type="text/javascript">
$("form").submit(function() {
if ($('#loading_image').length == 0) { //is the image on the form yet?
// add it just before the submit button
$(':submit').before('<img src="/images/ajax-loader.gif" style="display: none;" alt="loading" id="loading_image">')
}
$('#loading_image').show(); // show the animated image
$(':submit',this).attr('disabled','disabled'); // disable double submits
return true; // allow regular form submission
});
</script>
@iirving
Copy link
Author

iirving commented Aug 23, 2010

all explained at http://www.falsepositives.com/index.php/2010/08/16/show-a-loading-image-to-any-form-with-ajax-and-jquery/ Adding a “loading” image to (just about) any form on submit, with jQquery

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment