@using (Ajax.BeginForm("UpdateEmail", new AjaxOptions
{
HttpMethod = "POST",
OnFailure = "showMessage(xhr.responseJSON.TypeMessage, xhr.responseJSON.Message)",
OnSuccess = "showMessage(data.TypeMessage, data.Message); location.reload();",
OnBegin = "$('#btnRefresh').attr('disabled', true)",
OnComplete = "$('#btnRefresh').attr('disabled', false)",
}))
而且控制器:
public ActionResult UpdateEmail(EditEmailDTO model)
{
if (isValidCode)
{
//Code here to return a feedback json to be handle in OnSuccess callback - Working OK
return new EmptyResult();
}
else
{
//Here is the problem in production
Response.StatusCode = 422;
feedback = new { Success = false, Message = MessageFeedback.InvalidCode, TypeMessage= TypeMessageFeedback.Error.ToString().ToLower() };
}
catch (InvalidEmailException exception){ //Code Here }
return Json(feedback, JsonRequestBehavior.AllowGet);
}
}
当IM debuggin本地它完美的作品,onFailure处被触发,我在屏幕上得到的反馈。但是当我部署它时,我只能在Chrome开发工具控制台上看到服务器返回了422错误,并且此消息: Uncaught TypeError: Cannot read property 'TypeMessage' of undefined。
脚本在Ajax.BeginForm()产生:
(function(xhr,status,error
/**/) {
showMessage(xhr.responseJSON.TypeMessage, xhr.responseJSON.Message)
})
是否有生产和蒙山的Response.StatusCode错误本地debuggin区别吗?
2015-04-02
gog