HTML页面GET超链接请求转为POST请求

只要在超链接上写onclick调用下面的js即可

JS:代码

PARAMS格式:{'name':'哈哈','age':'100'}

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

发布了13 篇原创文章 · 获赞 7 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_39701913/article/details/88261427