fetch 发送 AJAX请求
生活随笔
收集整理的這篇文章主要介紹了
fetch 发送 AJAX请求
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>fetch 發(fā)送 AJAX請求</title>
</head>
<body><button>AJAX請求</button><script>//文檔地址//https://developer.mozilla.org/zh-CN/docs/Web/API/WindowOrWorkerGlobalScope/fetchconst btn = document.querySelector('button');btn.onclick = function(){fetch('http://127.0.0.1:8000/fetch-server?vip=10', {//請求方法method: 'POST',//請求頭headers: {name:'atguigu'},//請求體body: 'username=admin&password=admin'}).then(response => {// return response.text();return response.json();}).then(response=>{console.log(response);});}</script>
</body>
</html>
?
總結(jié)
以上是生活随笔為你收集整理的fetch 发送 AJAX请求的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 跨域 || Jsonp
- 下一篇: axios 发送 AJAX请求