AutoCAD 3DMAX C语言 Pro/E UG JAVA编程 PHP编程 Maya动画 Matlab应用 Android
Photoshop Word Excel flash VB编程 VC编程 Coreldraw SolidWorks A Designer Unity3D
 首页 > JavaScript

微信小程序 网络请求(post请求,get请求)

51自学网 http://www.wanshiok.com
微信小程序,网络请求post请求,get请求,微信小程序,网络请求(post请求,get请求)实例详解

微信小程序 网络请求

1.post请求:

onLoad: function() {   that = this;   wx.request( {    url: "url",    header: {     "Content-Type": "application/x-www-form-urlencoded"    },    method: "POST",    data: {},    complete: function( res ) {     console.log(res.data)    });     if( res == null || res.data == null ) {      console.error( '网络请求失败' );      return;     }    }   })  }, 

2.GET请求

onLoad: function () {  console.log('onLoad')  var that = this   wx.request({   url: 'http://json.bmbstack.com/cinemaList',   data: {},   method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT    header: {   'Accept': 'application/json'     }, // 设置请求的 header   success: function(res){    that.data.items= res.data   },   fail: function() {    // fail   },   complete: function() {    // complete   }  }) }

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!


微信小程序,网络请求post请求,get请求,微信小程序,网络请求(post请求,get请求)实例详解  
上一篇:vue.js学习笔记:如何加载本地json文件  下一篇:详解微信小程序开发之城市选择器 城市切换