Skip to content

Instantly share code, notes, and snippets.

@mgallego
Created May 13, 2011 07:04
Show Gist options
  • Select an option

  • Save mgallego/970111 to your computer and use it in GitHub Desktop.

Select an option

Save mgallego/970111 to your computer and use it in GitHub Desktop.
paso de form con Ajax
//esto supongo que está pendiente del DOM, por que pone document :)
$(document).ready(function() {
//esto detecta cuando el form con id="upload_form" hace submit
$('#upload_form').submit(function(){
//con esto hago el paso
$.ajax({
type: 'POST',
//saca la url del parametro "action" del form, que es /img/upload
url: $(this).attr('action'),
//coge los datos del form
data: $(this).serialize(),
//si todo ha salido bien cierra el fancybox
success: function(data) {
parent.$.fancybox.close();
}
});
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment