下面是我给大家整理的利用js使用post方式提交请求的方法,有兴趣的同学可以去看看。
一般都是写上隐藏的form标签,用<a href="#" onclick="..."/>来调用js函数然后submit
全部用js来写也行,以下是我在一个问答频道看见别人写的例子,放在这里
function post(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];
// alert(opt.name)
temp.appendChild(opt);
}
document.body.appendChild(temp);
temp.submit();
return temp;
}
//调用方法 如
post('pages/statisticsJsp/excel.action', {html :prnhtml,cm1:'sdsddsd',cm2:'haha'});上面是我整理给大家的利用JS使用POST方式提交请求的方法,希望今后会对大家有帮助。
相关文章:
以上就是利用JS使用POST方式提交请求的方法(结合代码详细解答)的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号