Skip to content

Instantly share code, notes, and snippets.

@traviskroberts
Created December 21, 2008 22:47
Show Gist options
  • Save traviskroberts/38782 to your computer and use it in GitHub Desktop.
Save traviskroberts/38782 to your computer and use it in GitHub Desktop.
// function to send the jQuery form object via AJAX
jQuery.fn.submitWithAjax = function() {
this.submit(function() {
// be sure to add the '.js' part so that it knows this is format:js
$.post(this.action + '.js', $(this).serialize(), null, "script");
return false;
})
return this;
};
$(document).ready(function() {
// once the page has completely loaded,
// make forms with the class "remote" submit via AJAX
$("form.remote").submitWithAjax();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment