使用fetch輕鬆解決JS跨域請求問題——無需CORS,jsonp

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));
});
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章