0
在我的代碼中,如果文件不存在於我的uploadDocument操作方法中,我想觸發$ ajax錯誤處理程序。也返回一個JSON對象。如何通過操作方法將對象傳遞給ajax.error處理程序mvc
上傳文檔操作方法
public ActionResult(HttpPostedFileBase[] uploadFiles, string requestIdEncrypted, string QuoteNoEncrypt)
{
if (uploadFiles[0] != null && ModelState.IsValid)
{
// file exist all good
}
// return an exception sending back json object
return new HttpStatusCodeResult(HttpStatusCode.BadRequest, Json(new { Success = false, Error = ExceptionFlag.ServiceFail }));
}
Ajax的錯誤處理程序
$.ajax({
type: "POST",
error: function(data, c, d)
{
// get the returned json object
}
})