Last active
March 23, 2021 17:20
-
-
Save deyvicode/9b905ac3af4e2ad4c4830fa3592bc68c to your computer and use it in GitHub Desktop.
Send form by jquery and 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
$('#form').submit(function (e) { | |
e.preventDefault(); | |
let data = new FormData(this); | |
$.ajax({ | |
url: '/route', | |
data: data, | |
processData: false, | |
contentType: false, | |
type: 'POST', | |
success: function (response) { | |
$('#form')[0].reset(); | |
// code | |
}, | |
error: function (error) { | |
// code | |
} | |
}); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment