Fetch被称为下一代ajax继承
https://github.com/whatwg/fetch
现在还没有被W3C纳入
var getObj = fetch("http://xxx.com/getData.php",{
method:"GET",
headers:{},
body:"id=3&name=jack"
});
getObj.then(function(data){
console.log(data.ok); //成功返回,则ok属性为true
var getTextObj = data.text();
getTextObj.then(function(res){
console.log(res);
});
},function(err){
console.log("失败");
})
本文介绍 Fetch API 的使用方法,这是一种用于替代传统 AJAX 请求的技术。通过示例代码展示如何发起 GET 请求,并处理响应数据。
1万+

被折叠的 条评论
为什么被折叠?



