Last active
November 14, 2017 22:39
-
-
Save claudiohilario/6958fce3f8c4372c65cc839fc89d02e9 to your computer and use it in GitHub Desktop.
Exemplo de envio através de ajax jQuery
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
$("form").submit(function(e) { | |
e.preventDefault(); | |
var data = $(this).serialize(); | |
var url = $(this).attr("action"); | |
var form = $(this); | |
$.ajax({ | |
type : 'post', | |
dataType : "json", | |
url : url, | |
data : data, | |
success : function(data){ | |
alert(data); | |
}, | |
error:function(data){ | |
alert('Ocorreu um erro!') | |
} | |
}); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment