狂风吹
狂风吹
  • 发布:2015-05-12 09:39
  • 更新:2015-05-13 09:26
  • 阅读:10714

ios平台下数据格式转换 %7B%22

分类:MUI

返回数据的转换

function getFistPageInfo() {
mui.ajax('https://test.com/test', {
data: {
username: 'username',
password: 'password'
},
dataType: 'text', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) {
//服务器返回响应,根据响应结果,分析是否登录成功;
console.log(data);
},
error: function(xhr, type, errorThrown) {
//异常处理;
console.log(type);
console.log(xhr);
}
});
}

调用此方法返回的报文如下:
%7B%22isSuccess%22%3A%22true%22%2C%22response%22%3A%7B%22message%22%3A%22success%22%2C%22code%22%3A%22M-Y000000%22%2C%22noticelist%22%3A%5B%5D%7D%2C%22sign%22%3A%22ad194b11807572131963140e16724ca6%22%7D

如果设置dataType:"json",则报pasererror !

这原本是json数据格式的,但到了ios平台下返回的报文已经进行了编码,此处如何得到正常的json数据?

2015-05-12 09:39 负责人:无 分享
已邀请:
狂风吹

狂风吹 (作者)

已经找到解决方法,使用javascript的decodeURIComponent对符号进行解码。

该问题目前已经被锁定, 无法添加新回复