I want to post some data to API Controller and receive a response like failure or Accept my controller is
public HttpResponseMessage Post([FromBody]Person person)
{
return new HttpResponseMessage(HttpStatusCode.OK);
}
and my front end code to send the Person data to My API is
function myfunc() {
$(function () {
var person = {'id':"1",'Name':"Mohammad",FamilyName:"Basiri"};
//preventDefault();
$.ajax({
type: "POST",
//contentType: "application/json",
data: (person),
url: "http://localhost:40027/api/Person",
dataType: 'json',
//contentType: "application/json",
success: function (d) {
alert("Done");
},
error: function (result) {
var e = JSON.stringify(result);
alert(e);
}
});
});
and the status code received is 200 OK but JQuery Function fires error if the content type which I commented be used then Person can not be sent my question is what can I do to send a response to JQuery that it receives it correct and doesn't fire error ?
thanks in advance