Last active
March 13, 2020 05:10
-
-
Save adamcrampton/758d02bd0a01d0697aaee63dd013693b to your computer and use it in GitHub Desktop.
Boilerplate for jQuery AJAX POST request
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
const endpoint = 'https://api.some.endpoint.test'; | |
const formId = 'this-form-id-value'; | |
const data = new FormData(document.getElementById('formId')); | |
$.ajax({ | |
async: true, | |
contentType: false, | |
processData: false, | |
url: endpoint, | |
method: 'POST', | |
data: data, | |
beforeSend: function(jqXHR, settings) { | |
}, | |
error: function(jqXHR, textStatus, errorThrown) { | |
}, | |
success: function(data, textStatus, jqXHR) { | |
}, | |
complete: function(jqXHR, textStatus) | |
{ | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment