在IE9下,当responseType设置为json, response.data为undefined
2018-03-21 10:03
381 查看
继续踩坑
![](http://www.sinaimg.cn/uc/myshow/blog/misc/gif/E___6706EN00SIGG.gif)
![](http://www.sinaimg.cn/uc/myshow/blog/misc/gif/E___6706EN00SIGG.gif)
![](http://www.sinaimg.cn/uc/myshow/blog/misc/gif/E___6706EN00SIGG.gif)
如题,不多说。When responseType is set to json, then response.data is undefined (only in IE9)ps:我用的是vue axios方案一:(亲测有效)在axios 中千万不要写,否则后果自负
![](http://www.sinaimg.cn/uc/myshow/blog/misc/gif/E___6721EN00SIGG.gif)
。当然如果这种方案出现了其他问题(目前没有发现),可以试试第二种。axios.defaults.responseType = 'json'方案二:在axios的响应头中设置就好啦~~~axios.interceptors.response.use( response => {// IE 8-9if (response.data == null && respo
935e
nse.config.responseType === 'json' &&response.request.responseText != null) {try {// eslint-disable-next-line no-param-reassignresponse.data = JSON.parse(response.request.responseText);} catch (e) {// ignored}}return response;})
![](http://www.sinaimg.cn/uc/myshow/blog/misc/gif/E___6706EN00SIGG.gif)
![](http://www.sinaimg.cn/uc/myshow/blog/misc/gif/E___6706EN00SIGG.gif)
![](http://www.sinaimg.cn/uc/myshow/blog/misc/gif/E___6706EN00SIGG.gif)
如题,不多说。When responseType is set to json, then response.data is undefined (only in IE9)ps:我用的是vue axios方案一:(亲测有效)在axios 中千万不要写,否则后果自负
![](http://www.sinaimg.cn/uc/myshow/blog/misc/gif/E___6721EN00SIGG.gif)
。当然如果这种方案出现了其他问题(目前没有发现),可以试试第二种。axios.defaults.responseType = 'json'方案二:在axios的响应头中设置就好啦~~~axios.interceptors.response.use( response => {// IE 8-9if (response.data == null && respo
935e
nse.config.responseType === 'json' &&response.request.responseText != null) {try {// eslint-disable-next-line no-param-reassignresponse.data = JSON.parse(response.request.responseText);} catch (e) {// ignored}}return response;})
相关文章推荐
- [Angular] Fetch non-JSON data by specifying HttpClient responseType in Angular
- 设置后台传送json的response.setContentType()格式
- The method setCharacterEncoding(String) is undefined for the type HttpServletResponse
- Struts学习_Jquery发送ajax请求以及datatype参数为text/JSON方式
- 使用data:JSON.stringify(object)遇到Uncaught TypeError: Converting circular structure to JSON
- hibernate 写createSQLQuery(sql)& 带异步async: false,抽取json对象的ajax 和dataType:"json"
- 为什么上传文件的表单需要设置enctype="multipart/form-data"
- jquery解析服务器端传输回来string字符,datatype为json时出现的问题
- response.setContentType 的设置
- 关天response.setContentType()和application/json
- 为什么上传文件的表单需要设置enctype="multipart/form-data"
- The method fromObject(String) is undefined for the type JSONObject
- 文件上传一些事(ie8/9下提示下载json文件)
- [iOS]将含有NSData数据的数组转化为json字符串报错:reason: 'Invalid type in JSON write (NSConcreteMutableData)
- spring 注解 @ResponseBody 返回JSON 设置不返回为 null 的值
- spring mvc当表单请求为application/json或enctype="multipart/form-data 过滤请求值参数,取不到请求参数问题
- Spring boot返回JSON类型响应及Content-Type设置
- ajax post data 获取不到数据,注意 content-type的设置 、post/get
- IE9下,原生JS设置元素left和top属性为数值不生效
- Could not find MessageBodyWriter for response object of type: application/json