res.data里包括html,wx.request 中res.data是服务器的整个网页源代码,怎么办?

下面是js里面的代码:

onLoad:function()

{

var that=this;

wx.request({

url: 'https://XXXXXXXXX.duapp.com/gzh/all.php',

data:{},

method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT

/* header: {

'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'

},*/

header: {

'content-type': 'application/json'

},

success: function(res){

that.setData({oneList:res.data});

// var d = JSON.parse(res.data);

//console.log(d.result[0].branceParentName);

console.log(res.data);

},

fail: function() {

// fail

},

complete: function() {

// complete

}

})

}

————————————————————————————————————————————————————

上述程序中通过调试发现,服务器返回的res.data 是整个网页的源代码。

在浏览器地址栏 输入上面的网址 返回的数据是这样的:

[{"id":"20","lei":"22","user":"\u5f97\u5230\u4e86","nr":"this id a twse","tel":"113333113333","tm":"2017-04-18 14:46:52"},{"id":"21","lei":"2222","user":"\u8001\u5b50","nr":"this id a twse","tel":"113333113333","tm":"2017-04-18 14:47:56"},{"id":"22","lei":"23","user":"\u5b59\u5b50","nr":"this id a twse","tel":"113333113333","tm":"2017-04-18 14:50:15"}]

然而 res.data 是这样的:

无标题文档

[{"id":"20","lei":"22","user":"\u5f97\u5230\u4e86","nr":"this id a twse","tel":"113333113333","tm":"2017-04-18 14:46:52"},{"id":"21","lei":"2222","user":"\u8001\u5b50","nr":"this id a twse","tel":"113333113333","tm":"2017-04-18 14:47:56"},{"id":"22","lei":"23","user":"\u5b59\u5b50","nr":"this id a twse","tel":"113333113333","tm":"2017-04-18 14:50:15"}]

————————————————————————————————————————————————————————————————

因为不是小程序需要的JSON格式,所以无法在小程序页面正常显示,好几天了没办法解决,跪求高手指点 !

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值