- XMLHttpRequest 对象:这是最常用的方法,它允许你使用 JavaScript 发送 HTTP 请求并接收响应。
var xhr = new XMLHttpRequest(); xhr.open('GET', '/my/url', true); xhr.onload = function () { if (this.status === 200) { console.log(this.responseText); } }; xhr.send();
- fetch() 函数:这是一个新的 API,它是基于 Promise 的,可以用来发送 HTTP 请求。
fetch('/my/url') .then(function (response) { return response.text(); }) .then(function (text) { console.log(text); });
- axios:这是一个基于 Promise 的 HTTP 库,可以轻松地发送 AJAX 请求。
axios.get('/my/url') .then(function (response) { console.log(response.data); });
- superagent:这是另一个用于发送 AJAX 请求的库,支持许多不同的 HTTP 方法,包括 GET、POST、PUT 和 DELETE。
request .get('/my/url') .end(function (err, res) { console.log(res.text); });

关注公众号『窗外天空』
获取更多建站运营运维新知!互联网创业、前沿技术......
最新评论
感谢分享,谢谢站长!!@天天下载
求同型号
能别用城通吗,缺钱缺这样啊
你好,请问有华硕ac68U可以使用的版本吗
xiaomi mini 是什么架构阿 是mipsel_24kc架构ma