zoukankan      html  css  js  c++  java
  • 小程序 wx.request

    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)
      }
    })
  • 相关阅读:
    php对接微信小程序支付
    微信小程序/网站 上传图片到腾讯云COS
    php+smarty轻松开发微社区/微论坛
    精简商务合同管理系统开发
    MyBatis返回map数据
    MyBatis(五)select返回list数据
    MyBatis(四)多参数处理问题
    MyBatis(三)MyBatis的增删改查
    dbconfig.properties
    MyBatis入门(二)接口式编程
  • 原文地址:https://www.cnblogs.com/sklhtml/p/9718188.html
Copyright © 2011-2022 走看看