JS函数实现创建并发送表单
以POST方法为例:
function post(URL,DATA){
var temp = document.createElement("form");
temp.action = URL;
temp.method = "POST";
temp.style.display = "none";
for(x in DATA){
var y = document.createElement("textarea");
y.name = x;
y.value = DATA[x];
temp.appendChild(y);
}
document.body.appendChild(temp);
temp.submit();
}
其中URL为action的目标文件,DATA是表单的键值对对象。
    所属分类:JavaScript     发表于2021-08-12