I am using a public api for testing that responds to get, post, put, and delete and when attempting to create a http-delete request using jQuery.ajax() my response is undefined. This seems strange as I have successfully received a response using Javascript Fetch to make the request. Is my ajax http-delete request malformed?
Input
$.ajax({
url: "https://reqres.in/api/users/2",
type: "DELETE",
success: function (response) {
console.log("Success: " + response);
},
error: function (response) {
console.log("Failure: " + response);
},
});
Output
Success: undefined
Things I've Tried
- changing property 'type' to 'method'
- added a property 'error' but the logic goes to success with no response.
- googling various ajax delete requests and trying those with the reqres.in API
- successfully got a response using http-delete request with javascript fetch using the reqres.in api
- successfully got a responses on put, post, and get requests using ajax
- using different browsers (ie. chrome, edge, firefox)