以下是我的ajax调用,它工作正常但始终成功。未能正常工作ASP.NET MVC Ajax JQuery
$.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);
}
});
如何使失效功能激活。在控制器类,我做
return new HttpStatusCodeResult(500, "Error message");
但在失败的消息框不会出现,我需要什么做的就是失败的工作并显示一条消息。
这'error'不'failure'。 –