postcall( '/index.php', {
UserName: 'UserName',
});
function postcall( url, params, target){
var tempform = document.createElement("form");
tempform.action = url;
tempform.method = "post";
tempform.style.display="none"
if(target) {
tempform.target = target;
}
for (var x in params) {
var opt = document.createElement("input");
opt.name = x;
opt.value = params[x];
tempform.appendChild(opt);
}
var opt = document.createElement("input");
opt.type = "submit";
tempform.appendChild(opt);
document.body.appendChild(tempform);
tempform.submit();
document.body.removeChild(tempform);
}
零五网 - 为热爱技术的人而生!
原生js模拟表单提交
0 Previous ArticleVue 中获取 v-for 的 index 索引值
Next Article JavaScript倒计时跳转网页