1.同步和异步
(1)同步:事情一件一件的做
(2)异步:事情可以同时做,前一件事情的执行,不会影响后一件事情的执行
2.XMLHttpRequest对象
var xhr =new XMLHttpRequest()
3.发送get请求
(1)创建XMLHttpRequest对象(2)发送请求
请求行:xhr.open(类型,url,true)
请求头:et请求不需要设置请求头,按浏览器默认的就可以
请求体:get请求没有请求体
var bt = document.getElementById(‘bt‘) bt.onclick = function () { var xhr =new XMLHttpRequest() xhr.open("get", "02-get.php?username=pp&password=123456") xhr.send() }
原文:https://www.cnblogs.com/zhaodz/p/11628520.html