Skip to content

Instantly share code, notes, and snippets.

@marciobarrios
Created March 27, 2009 05:10
Show Gist options
  • Save marciobarrios/86549 to your computer and use it in GitHub Desktop.
Save marciobarrios/86549 to your computer and use it in GitHub Desktop.
Plugin básico para enviar formularios via ajax
(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