XMLHttpRequest里的setRequestHeader到底怎么用
1 回答

MMTTMM
TA貢獻1869條經驗 獲得超4個贊
var method = "get";
var url = "test.php";
var async = true;
var data = "username=" + encodeURIComponent(username) + "&password=" + encodeURIComponent(password)
xmlHttp.open(method, url, async);
//設置回調函數,接收服務器端的信息以進行處理
xmlHttp.onreadystatechange = getServerInfo;
//想服務器端發送內容,為什么不起作用呢?
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-Length", data.length);
xmlHttp.send(data);
- 1 回答
- 0 關注
- 741 瀏覽
添加回答
舉報
0/150
提交
取消