Skip to content

Instantly share code, notes, and snippets.

@RimonEkjon
Forked from marciobarrios/jquery_ajaxify.js
Created August 26, 2014 04:05
Show Gist options
  • Save RimonEkjon/cefc01c2f138ea8cc814 to your computer and use it in GitHub Desktop.
Save RimonEkjon/cefc01c2f138ea8cc814 to your computer and use it in GitHub Desktop.
(function() {
$.fn.ajaxify = function(options) {
$(this).submit(function(e) {
var form = $(this);
$.ajax({
type : form.attr('method'),
url : form.attr('action'),
data : form.serialize(),
error : options.error,
success : options.success,
});
return false;
});
}
})();
//use
$('form').ajaxify(
{success: success_method_name,
error: error_method_name});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment