- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我如何在 dataFilter 中捕获 http 代码状态?有以下代码:
$.ajaxSetup ({
dataFilter: function (data) {
//need know http status for change data
return data;
}
});
最佳答案
您无法使用 dataFilter 来执行此操作。来自文档:
dataFilter(data, type)Function A function to be used to handle the raw response data of XMLHttpRequest.This is a pre-filtering function to sanitize the response. You should return the sanitized data. The function accepts two arguments: The raw data returned from the server and the 'dataType' parameter.
加上您引用的ajaxSetup
,用于定义进行 jQuery ajax 调用时的默认 ajax 设置。该代码实际上并没有进行 ajax 调用。
jQuery ajax 方法有一个 statusCode
属性,其中包含您要查找的内容。您还可以使用 success
和 error
,它们根据结果状态代码进行调用。
阅读文档中的所有内容:jQuery.ajax() API
关于jquery - 在 dataFilter 中捕获 http 代码状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13037747/
我使用 jQuery.ajax() 通过 jsonp 从外部 api 获取数据。 这是我的 ajax 设置: var ajax_options = { dataType: 'jsonp',
据我了解,只有回调dataFiltered,它用于整个表。所有过滤器都会无差别地触发它。 是否可以获取特定单个 header 过滤器的回调?这样我就可以在某个 header 过滤器激活后立即调用函数?
我为返回 JSON 数据的 jQuery 调用定义了一个 ajax dataFilter,以确保 .Net 编码的日期在返回时自动转换为 JavaScript 日期: $.ajaxSetup({
我如何在 dataFilter 中捕获 http 代码状态?有以下代码: $.ajaxSetup ({ dataFilter: function (data) { //need k
我在 jquery ajaxsetup 上使用以下 datafilter 选项: dataFilter: function(data) { var msg;
现在有人可以免费(如果可能的话开源)替代 Telerik DataFilter 吗?或者可能是如何完成此操作的教程? 我真的很想在我的项目中使用这样的过滤器。 http://www.telerik.c
如何从来自 ajax 调用的 JSON 数据生成修改后的有效 JSON 数据字符串。有必要使用 dataFilter 来完成此操作。 ajax调用的retData(返回的数据)是: {"8":"vac
我正在尝试让 Sync ( https://github.com/hyperoslo/Sync) 在我的“em”Xcode iOS Swift 项目中工作。我有 Carthage 的框架依赖经验,所以
我是一名优秀的程序员,十分优秀!