- Joined
- Dec 14, 2020
- Messages
- 3
- Reaction score
- 0
I'm having an issue with ajax. I have an api set up that takes json as a post value and returns json as a result. It works fine using the postman app to test it. It also works when I send the data from an ajax call as get. But as soon as I call it as post data, the post data is empty.
Using the console in Chrome I can see the values of the post and get vars.
The ajax code is:
Any ideas why the post var isn't working?
Using the console in Chrome I can see the values of the post and get vars.
The ajax code is:
Code:
$( document ).ready(function() {
var the_data = {
request: {.....},
limits: {.....},
.....
};
$.ajax({
url: "http://localhost/api/index.php",
type: "POST",
datatype: "json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(the_data),
success: function(data){
console.log(data);
},
error: function(jqXHR, textStatus, errorThrown){
console.log(errorThrown);
}
});
});
Any ideas why the post var isn't working?