var select=document.getElementById('selectid');
var selectval=select.options[select.options.selectedIndex].value;
if(selectval){
var data = "selectval=" + selectval
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "Belong");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
}
//POST请求相对GET请求需要加入请求头部
JSP利用AJAX POST请求上传表单
最新推荐文章于 2020-12-15 20:30:18 发布