wx.request({
  url: 'https://hanwslh5.qcloud.la/weapp/HelloWorld',

  对于 GET 方法的数据,会将数据转换成 query string(encodeURIComponent(k)=encodeURIComponent(v)&encodeURIComponent(k)=encodeURIComponent(v)...

  // get的方法
  // data:{
    // "p1": 1,
    // "p2": 'p2'
  // },
  // method: 'GET',
 
  

  对于 POST 方法且 header['content-type'] 为 application/x-www-form-urlencoded 的数据,会将数据转  querystring (encodeURIComponent(k)=encodeURIComponent(v)&encodeURIComponent(k)=encodeURIComponent(v)...)

  //post的方法urlencode
  // data:{
    // "p1": 1,
    // "p2": 'p2'
  // },
  // header:{
    // 'content-type': 'application/x-www-form-urlencoded'
  // },
  // method: 'POST',

  

  对于 POST 方法且 header['content-type'] 为 application/json 的数据,会对数据进行 JSON 序列化

  //post的方法 Json
  data:{
    "p1": 1,
    "p2": 'p2'
  },
  header:{
    'content-type': 'application/json'
  },
  method: 'POST',
  success: function(res){
    console.log(1111)
    console.log("-----in success-----")
    console.log(res)
    console.log(res.statusCode)
    if (res.StatusCode==200){
      console.log(res.statusCode)
    }
  },
  fail: function(res){
    console.log("-----in fail-----")
    console.log(res)
  },
  complete: function(res){
    console.log("-----in complete-----")
    console.log(res)
  }
})

小程序 wx.request的更多相关文章

  1. 微信小程序wx.request接口

    微信小程序wx.request接口 wx.request是小程序客户端与服务器端交互的接口 HTTPS 请求 一个微信小程序,只能同时(同时不能大于5个)有5个网络请求 wx.request(OBJE ...

  2. 监控微信小程序wx.request请求失败

    在微信小程序里,与后台服务器交互的主要接口函数是wx.request(),用于发起 HTTPS 网络请求.其重要性不言而喻.然而,却经常遇到请求失败的问题,笔者特意谷歌"wx.request ...

  3. 微信小程序wx.request请求用POST后台得不到传递数据

    微信小程序的wx.request请求,method设为POST并向后台传递数据,但从后台返回的信息来看后台并没有获得传递的数据 wx.request({              url: 'url' ...

  4. 坑:微信小程序wx.request和wx.uploadFile中传参数的区别

    微信小程序中通过组件<form>提交表单的时候,在js中通过e.detail.value得到所提交表单的json格式数据.一般提交表单我们都是通过wx.request请求,提交表单数据,通 ...

  5. 微信小程序 wx.request

    onLoad: function () { var that = this console.log('https://free-api.heweather.com/s6/weather?locatio ...

  6. 小程序wx.request的封装

    第一次做小程序项目,这个封装方法是同学推荐的一个网址,对我帮助很大,如果想看代码部分,请看网址详细介绍 网络请求都写在Page里,每个请求都要重复的写wx.request以及一些基础配置: 每个页面里 ...

  7. 微信小程序- wx.request请求不到数据

    小程序官方文档手册 https://mp.weixin.qq.com/debug/wxadoc/dev/ 小程序开发问答社区 http://www.henkuai.com/forum.php wx.r ...

  8. 小程序 wx.request ajax示例

    简单示例 https://developers.weixin.qq.com/miniprogram/dev/api/network-request.html wx.request({ method: ...

  9. 微信小程序wx.request请求服务器json数据并渲染到页面

    [原文出自]: https://blog.csdn.net/weixin_39927850/article/details/79766259 微信小程序的数据总不能写死吧,肯定是要结合数据库来做数据更 ...

  10. 微信小程序wx.request的简单封装

    前言 之前写小程序,每次请求后台时都直接调用原生的API,wx.request,每次都要写url,data,回调函数等,正好前段时间,小程序项目需要添加新内容,趁此机会,做一个封装的请求工具,比较简单 ...

随机推荐

  1. js 实现的页面图片放大器以及 event中的诸多 x

    背景: 淘宝.天猫等电商网站浏览图片时可以查看大图的功能: 思路: 思路很简单,两张图片,一张较小渲染在页面上,一张较大是细节图,随鼠标事件调整它的 left & top; 需要的知识点: o ...

  2. codeforces444A

    DZY Loves Physics CodeForces - 444A DZY loves Physics, and he enjoys calculating density. Almost eve ...

  3. koa-session 记录当前会话内容

    最近做毕设需要在nodejs服务器下记录当前用户账号,所用的node框架是koa,所以相对应配套的用了koa-session,发现和之前学的session差不多,都是会话级别的. 一.session和 ...

  4. luogu P2071 座位安排

    这个题可以被分为两部分 1.匈牙利算法(板子) 2.邻接表存图(好像这不能称为第二部分) 每一排能坐两个人,那就把一排拆成两个点, 用匈牙利算法求最大匹配 每个人都只想坐两排,说明每个人只会连四条边 ...

  5. MT【322】绝对值不等式

    已知 $a,b,c\in\mathbb R$,求证:$|a|+|b|+|c|+|a+b+c|\geqslant |a+b|+|b+c|+|c+a|$ 分析:不妨设$c=\max\{a,b,c\},\d ...

  6. MySQL INSERT UPATE DELETE语句

    插入完整一行 INSERT INTO customers(cust_name,cust_contact,cust_email,cust_address,cust_city,cust_state,cus ...

  7. idea搭建springboot

     1.创建新项目 2.继续项目配置 Name:项目名称Type:我们是Maven构建的,那么选择第一个Maven ProjectPackaging:打包类型,打包成Jar文件Java Version: ...

  8. python之路day02--格式化输出、初始编码、运算符

    格式化输出 格式化输出替换字符串.字符串中%占位符,,%%s就是代表百分号,不代表占位符s 字符串 stringd 数字 dight name = input('请输入你的名字:') age = in ...

  9. mysql5.7 修改root密码无法登陆原因

    升级的mysql5.7修改完root账户密码后仍然无法登陆,查阅资料可能和user表的plugin 字段为空有关. 1.首先将my.ini中加入在[mysqld]节点上加skip-grant-tabl ...

  10. 2017-12-19python全栈9期第四天第二节之列表的增删查改之删除的pop和del和remove和clear

    #!/user/bin/python# -*- coding:utf-8 -*-li = ['zs','ls','ww','zl']# name = li.pop(1) #按索引位置删除有返回值# n ...