日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

AJAX POST 请求

發布時間:2025/4/16 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 AJAX POST 请求 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>AJAX POST 請求</title><style>#result{width:200px;height:100px;border:solid 1px #903;}</style> </head> <body><div id="result"></div><script>//獲取元素對象const result = document.getElementById("result");//綁定事件result.addEventListener("mouseover", function(){//1. 創建對象const xhr = new XMLHttpRequest();//2. 初始化 設置類型與 URLxhr.open('POST', 'http://127.0.0.1:8000/server');//設置請求頭xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');xhr.setRequestHeader('name','dym');//3. 發送xhr.send('a=100&b=200&c=300');// xhr.send('a:100&b:200&c:300');// xhr.send('1233211234567');//4. 事件綁定xhr.onreadystatechange = function(){//判斷if(xhr.readyState === 4){if(xhr.status >= 200 && xhr.status < 300){//處理服務端返回的結果result.innerHTML = xhr.response;}}}});</script> </body> </html>

?


總結

以上是生活随笔為你收集整理的AJAX POST 请求的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。