- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
对于 Spring MVC Controller 中的验证错误,我将自定义 header error 设置为响应 header 。我可以在 Firefox 3.5 中访问该响应 header 。但在 IE 8 中不行。请告诉我向 Jquery 客户端显示自定义错误消息的正确方法。
var jqxhr=$.post("saveAcc.htm",{ data: data});
jqxhr.success(function() {
alert("Saved");
});
jqxhr.error(function(thrownError){
fnSetError(jqxhr.getResponseHeader('error'));
alert(jqxhr.getAllResponseHeaders()); //returns empty
//alert('responseText '+ thrownError.responseText);
alert(jqxhr.getResponseHeader('error')); //return null
oTable.fnReloadAjax();
});
最佳答案
如果要调用JS错误处理函数,请在服务器上抛出异常。
或者,您可以将 HTTPStatus 设置为 500 或其他错误状态
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
//response.setStatus(500);
但我认为你的做法是错误的。验证错误不是应用程序错误,您应该在成功消息中处理这些错误。
jqxhr.success(function(data) {
if(data['validationMessages'].length > 0 ) {
//deal with the validation issues
}
});
这可能有帮助:http://outbottle.com/spring-3-web-mvc-exception-handling-incorporating-ajax/
关于jquery - getResponseHeader 在 IE 8 中返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8666208/
我需要从另一个页面获取值。但我通过以下代码收到此错误。我该如何修复它? $(document).ready(function() { $("[name='submit']").
我有一个通过 ajax 提交的表单。我正在使用 jquery 表单插件。我想做的是获取从我的服务器返回的“位置” header 。我可以在 Firebug 中看到它。但是每当我在成功回调中调用 get
我在使用我在 Greasemonkey 脚本上调用 getResponseHeader 时获得的值时遇到问题。 首先,我声明了以下全局变量: size = 0; maxS = 153600; // M
在我的 ajax 调用中,responseHeader('Location') FF 始终为空。有谁能够帮助我?顺便说一下,它是一个 CORS。 $.ajax({ ur
我在 .NET 4 上有一个 asp.NET WCF。此服务用于对用户进行身份验证。我们正在提交用户名和密码,然后应该返回一个包含身份验证 cookie 的 HTTP header 。使用本地托管的测
我有这个代码: Connector conn = FrameworkUtil.getConnector(context, ALFRESCO_ENDPOINT_ID); ConnectorContext
我遇到了一个非常令人沮丧的错误。我不太确定发生了什么,但我认为 xhr 正在响应 header 上进行某种缓存。 我的应用程序正在使用 devise_token_auth 进行后端身份验证服务。我们将
我使用的是 jQuery 1.7.1。以及Ajax Form plugin ,最新版本可用。当我执行 Ajax 请求时,例如: $('form').ajaxForm ( { success:
我试图覆盖 XMLHttpRequest 对象上的 getResponseBody 方法。代码看起来是这样的: xhr.onreadyStateChange = function(){ if
对于 Spring MVC Controller 中的验证错误,我将自定义 header error 设置为响应 header 。我可以在 Firefox 3.5 中访问该响应 header 。但在
在 Postman 中,我试图检索从 post 调用返回的 session 值,并在另一个 get 调用中使用它。 我的意思是,我是通过 Postman 打电话的: curl -X POST \
为什么 IE 不让我看到带有 getResponseHeader() 的获取 Content-Length header ? 我知道那里正在发送 header ;我可以用 Wireshark 看到它们
我是一名优秀的程序员,十分优秀!