js 模拟form表单post提交

 1 var generateHideElement = function (name, value) {
 2 var tempInput = document.createElement("input");
 3 tempInput.type = "hidden";
 4 tempInput.name = name;
 5 tempInput.value = value;
 6 return tempInput;
 7 }
 8 
 9 var form = document.createElement("form");
10 document.body.appendChild(form);
11 
12 
13 var jData = generateHideElement("jData", "11"),
14 jsongroups = generateHideElement("jsongroups", "22"),
15 cacheKey = generateHideElement("cacheKey", "33"),
16 execlName = generateHideElement("execlName", "44");
17 
18 
19 
20 
21 form.appendChild(jData);
22 form.appendChild(jsongroups);
23 form.appendChild(cacheKey);
24 form.appendChild(execlName);
25 form.method = "post";
26 form.action = ""
27 form.submit();

 

posted @ 2019-03-14 10:13  没事就更  阅读(10510)  评论(0编辑  收藏  举报