zoukankan      html  css  js  c++  java
  • 微信小程序开发POST请求

    onLoad: function() {  
        that = this;  
        wx.request( {  
          url: "http://op.juhe.cn/onebox/weather/query",  
          header: {  
            "Content-Type": "application/x-www-form-urlencoded"  
          },  
          method: "POST",  
         //data: { cityname: "上海", key: "1430ec127e097e1113259c5e1be1ba70" },  
          data: Util.json2Form( { cityname: "上海", key: "1430ec127e097e1113259c5e1be1ba70" }),  
          complete: function( res ) {  
            that.setData( {  
              toastHidden: false,  
              toastText: res.data.reason,  
              city_name: res.data.result.data.realtime.city_name,  
              date: res.data.result.data.realtime.date,  
              info: res.data.result.data.realtime.weather.info,  
            });  
            if( res == null || res.data == null ) {  
              console.error( '网络请求失败' );  
              return;  
            }  
          }  
        })  
      }
  • 相关阅读:
    三范式
    作用域
    函数传参
    js数据类型
    纯css小图标
    js生成div
    js模拟微信聊天窗口
    js图片切换
    js this指向
    常用实体字符
  • 原文地址:https://www.cnblogs.com/weiboyuan/p/6047750.html
Copyright © 2011-2022 走看看