使用ajax XMLHttpRequest发送GET、POST数据
 微wx笑
微wx笑 2022-07-27【前端开发】
 2022-07-27【前端开发】 125
125 5
 5 0关键字:
ajax
 0关键字:
ajax  
使用ajax XMLHttpRequest发送GET、POST数据
使用ajax XMLHttpRequest发送GET、POST数据
POST数据
| 1 2 3 4 5 6 7 8 9 10 11 12 13 | var data = new FormData();data.append('user', 'person');var xhr = new XMLHttpRequest();xhr.open('POST', 'https://czsc.ivu4e.com/doc88/savebook.php', true);xhr.responseType = 'text';xhr.onload = function () { if (this.status == 200) {   console.log(this.response); }else{    console.log(this.status); }};xhr.send(data); | 
GET数据
| 1 2 3 4 5 6 7 8 9 10 11 | varxhr = newXMLHttpRequest();xhr.open('GET', 'https://s.weibo.com/top/summary?cate=realtimehot', true);xhr.responseType = 'text';xhr.onload = function() { if(this.status == 200) {   console.log(this.response); }else{    console.log(this.status); }};xhr.send(); | 
本文由 微wx笑 创作,采用 署名-非商业性使用-相同方式共享 4.0  许可协议,转载请附上原文出处链接及本声明。
原文链接:https://www.ivu4e.cn/blog/front/2022-07-27/1325.html








