Created
February 18, 2018 16:45
-
-
Save ChristopherDosin/565fd1f3c05f2277a974216ab0adb1d9 to your computer and use it in GitHub Desktop.
Send form with ajax
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
$('#id-form button[type=submit]').click(function(e){ | |
e.preventDefault(); | |
$(this).text('Einen moment...'); | |
var form = jQuery(this).parents("form:first"); | |
var dataString = form.serialize(); | |
var formAction = form.attr('action'); | |
$.ajax({ | |
type: "POST", | |
url : formAction, | |
data : dataString, | |
success : function(data){ | |
console.log(data); | |
}, | |
error : function(data){ | |
var errors = $.parseJSON(data.responseText); | |
console.log(errors); | |
} | |
},"json"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment