使用js发送post请求
1.先将需要传递的参数封装
2.然后调用提前封装好httpPost方法即可
var params = {
"startTime": startTime,
"endTime": endTime,
"type": type
};
httpPost(contextPath + "/mobile/index", params);
//发送POST请求跳转到指定页面
function httpPost(URL, PARAMS) {
var temp = document.createElement("form");
temp.action = URL;
temp.method = "post";
temp.style.display = "none";
for (var x in PARAMS) {
var opt = document.createElement("textarea");
opt.name = x;
opt.value = PARAMS[x];
temp.appendChild(opt);
}
document.body.appendChild(temp);
temp.submit();
return temp;
}