ajax发送异步
2017-09-03 本文已影响0人
魔王恩
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(“键”,“值”)