84669 orang belajar
152542 orang belajar
20005 orang belajar
5487 orang belajar
7821 orang belajar
359900 orang belajar
3350 orang belajar
180660 orang belajar
48569 orang belajar
18603 orang belajar
40936 orang belajar
1549 orang belajar
1183 orang belajar
32909 orang belajar
根据这篇文章微信小程序使用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)