The following is my ajax call which is working fine but its always success.
$.ajax({
type: "POST",
url: '@(Request.RawUrl + "/postcomment")',
dataType: "json",
data: data,
contentType: "application/json; charset=utf-8",
success: function() {
alert('success');
},
failure: function(response) {
alert(response.d);
}
});
How can I cause the failure function to be activated. In the controller class, I'm doing
return new HttpStatusCodeResult(500, "Error message");
But in the failure message box doesn't appear, what do I need to do to get failure to work and display a message.
errornotfailure.