84669 personnes étudient
152542 personnes étudient
20005 personnes étudient
5487 personnes étudient
7821 personnes étudient
359900 personnes étudient
3350 personnes étudient
180660 personnes étudient
48569 personnes étudient
18603 personnes étudient
40936 personnes étudient
1549 personnes étudient
1183 personnes étudient
32909 personnes étudient
根据这篇文章微信小程序使用ajax请求到自己的网站,可以在微信小程序中使用XMLHttpRequest对象实现ajax请求,但实际测试,在page/index/index.js中添加
onLoad() { console.log(XMLHttpRequest); console.log('onLoad'); }
在开发者工具上打印结果却是undefined,是文章错误,还是小程序更新删除了?
以我所知,微信小程序是用MINA开发的。并没有实现浏览器之类的XMLHttpRequest的方法。只有wx.request 这个api
xmlhttp=new XMLHttpRequest(); console.log(xmlhttp);
微信小程序没有window与document对象,只能使用小程序的API,比如:
wx.request({ url: 'test.php', //仅为示例,并非真实的接口地址 data: { x: '' , y: '' }, header: { 'content-type': 'application/json' }, success: function(res) { console.log(res.data) } })
wx.request(OBJECT)
以我所知,微信小程序是用MINA开发的。
并没有实现浏览器之类的XMLHttpRequest的方法。
只有wx.request 这个api
微信小程序没有window与document对象,只能使用小程序的API,比如:
wx.request(OBJECT)