I'm trying to get application/json
data sets from an ajax call.
Using the same setting that I initially tested on Postman where I got the data normally from the request, I can't get the proper result that I get from Postman with my JavaScript code.
Following is the source I'm trying to work out.
$.ajax({
url: myUrl,
type: "POST",
contentType: "application/json",
success:function(res){
alert(res);
},
error:function(request,status,error){
alert(request+" : "+status+" : "+error);
}
});
Execute the source above, it goes into the error part and I get the alert message like ' [object Object] : error : '. [object Object] for request, error for status, and nothing for the error.
I've tried to put different settings there like async, cache, tried to put the contentType in a separated header setting like header: {"Content-Type":"appplication/json"} but none of them has worked yet.
How can I make it work? Thank you ahead for helps.