700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 使用js发送post请求

使用js发送post请求

时间:2020-11-14 18:46:59

相关推荐

使用js发送post请求

使用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;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。