此外,也可以使用send方法傳遞參數。使用send方法傳遞參數使用的是POST方法,需要設定Content-Type頭信息,模擬HTTP POST方法發送壹個表單,這樣服務器才會知道如何處理上傳的內容。參數的提交格式和GET方法中url的寫法壹樣。設置頭信息前必須先調用open方 法。 例如:!--[if !supportLists]-->1 !--[endif]-->xmlHttpRequest.open(POST,login.jsp,true);!--[if !supportLists]-->2 !--[endif]-->xmlHttpRequest.setRequestHeder(Content-Type,application/x--form-urlencoded;charset=UTF-8);!--[if !supportLists]-->3 !--[endif]-->xmlHttpRequest.send(user=+username+&pwd=+password);
需要註意的是根據提交方式的不同,兩種提交方式分別調用後臺的doGet方法和doPost方法。