微信小程序接受asp.net 返回的json值处理

来源:互联网 发布:mysql服务无法启动1067 编辑:程序博客网 时间:2024/06/05 01:16
        wx.request({
            url: 'https://l网址er.aspx',
            data: {
                openId: wx.getStorageSync('openId'),
                requestType: "query"
            },
            success: function (response) {
                // 
                //console.log(response)
                //console.log(response.data)
                //console.log(response.statusCode)
                if (response.statusCode == '200') {
                    var count = response.data.indexOf("\r\n\r\n<!DOC");
                    var str = response.data.substring(0, count)
                    var json = JSON.parse(str)
                    //保存信息
                    console.log(str+"长度" + json.length)
                } else {
                    wx.showToast({
                        title: '信息读取失败,请联系客服!',
                        icon: 'success',
                        duration: 1500
                    })
                }
            }
        });
0 0
原创粉丝点击