ooo*_*sss 3 javascript get node.js
在 vanilla JavaScript 中向服务器发送 GET 请求的最佳方式是什么?
小智 6
在 vanilla javascript 中,您可以使用fetch API。
fetch('http://example.com/movies.json')
.then((response) => {
return response.json();
})
.then((myJson) => {
console.log(myJson);
});
Run Code Online (Sandbox Code Playgroud)
您可以执行重定向来执行同步 GET 请求:
var url = 'http://domain/path/?var1=&var2=';
window.location = url;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5715 次 |
| 最近记录: |