以下是我的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'。 –