通过本文主要向大家介绍了get和post的区别,get和post请求的区别,get post,get与post方式的区别,http get post 区别等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
微信小程序 网络请求
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;
}
}
})
},
</div>
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
}
})
}
</div>
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
</div>
