您的位置:首页 > Web前端

使用fetch轻松解决JS跨域请求问题——无需CORS,jsonp

2016-04-15 10:31 1211 查看
fetch(url, {

method: "POST",

mode: "no-cors",

headers: {

"Content-Type": "application/x-www-form-urlencoded"

},

body: "请求参数"

}).then(function(res) {

console.log("Response succeeded?", JSON.stringify(res.ok));

console.log(JSON.stringify(res));

}).catch(function(e) {

console.log("fetch fail", JSON.stringify(params));

});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  跨域 javascript fetch