Created
January 10, 2014 14:03
-
-
Save heat/8352625 to your computer and use it in GitHub Desktop.
como enviar um post por ajax tratando o retorno. Evitando assim o redirecioanmento do browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#formid').on('submit', function(event) { | |
event.preventDefault(); | |
var $form = $(this); | |
var url = $form.attr('action'); | |
$.post( url, $form.serialize()) | |
.done( function(data) { | |
//trata caso tenha voltado um codigo 200 | |
}) | |
.fail( function( ajx, sc) { | |
alert("problemas durante a requisição.\n" + sc); }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment