get提交数据直接在url后面追加,格式为:
xxx.php?username=xxx
get方式没有请求主体,所以send(null)
post提交时默认的content-type为text/plain,所以要在open与send之间设置一下请求的content-type格式。即
xhr.getRequestHeader(“Content-Type”,“application/x-www-form-urlencoded”)
且请求主体放在send(“键”,“值”)
get提交数据直接在url后面追加,格式为:
xxx.php?username=xxx
get方式没有请求主体,所以send(null)
post提交时默认的content-type为text/plain,所以要在open与send之间设置一下请求的content-type格式。即
xhr.getRequestHeader(“Content-Type”,“application/x-www-form-urlencoded”)
且请求主体放在send(“键”,“值”)
本文标题:ajax发送异步
本文链接:https://www.haomeiwen.com/subject/lwujjxtx.html
网友评论