Created
October 21, 2022 08:14
-
-
Save skangmy/6c585d12ad776db0cdbb4eb63bf672be to your computer and use it in GitHub Desktop.
jquery http post function
This file contains hidden or 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
function post(url, data) { | |
return new Promise((resolve, reject) => { | |
$.ajax({ | |
url, | |
dataType: 'json', | |
type: 'post', | |
contentType: 'application/json', | |
data: JSON.stringify(data), | |
processData: false, | |
success: function (response, textStatus, jQxhr) { | |
resolve(response); | |
}, | |
error: function (jqXhr, textStatus, errorThrown) { | |
reject(errorThrown); | |
}, | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment