JavaScript实现页面POST请求


通过创建节点,添加表单,最后添加到body子标签中

function htmlPost(){

  var data = {"test","测试"}

  myPost("url",data)

}

function myPost(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.test = x;
temp.appendChild(opt);
}
document.body.appendChild(temp);
temp.submit();
return temp;
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM