Skip to content

Instantly share code, notes, and snippets.

@keithcollins
Created June 15, 2013 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keithcollins/5788794 to your computer and use it in GitHub Desktop.
Save keithcollins/5788794 to your computer and use it in GitHub Desktop.
First, we take the ID and action of the form being called. Next, we post the serialized form data to the handler specified in the form's action attribute. On success, the handler should output a message to indicate all is well, or an error indicating otherwise. Remember that div at the bottom of the registration form? This is where the returned …
$('.ajaxForm').on('submit', function(e) {
var formId = $(this).attr('id'),
doAction = $(this).attr('action');
$.post(doAction, $(this).serialize(),
function(data) {
$('#'+formId+'_result').html(data);
});
e.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment