var openPostWindow =function (url, data1) {//url 为请求地址,data1为需要请求的数据var tempForm = document.createElement("form");//创建form表单,以下数form表单的各种参数tempForm.id = "tempForm1";tempForm.method = "post";tempForm.action = url;var hideInput1 = document.createElement("input");//创建标签 <input></input> 标签 然后设定属性,最后追加为 form标签的子标签hideInput1.type = "hidden";hideInput1.name = "result";hideInput1.value = data1;var hideInput2 = document.createElement("input");hideInput2.type = "hidden";hideInput2.name = "CSRFToken";hideInput2.value = JSON.parse(data1).CSRFToken;var hideInput3 = document.createElement("input");hideInput3.type = "hidden";hideInput3.name = "l";hideInput3.value = data1.length;tempForm.appendChild(hideInput1);tempForm.appendChild(hideInput2);tempForm.appendChild(hideInput3);if (document.all) {tempForm.attachEvent("onsubmit", function () {}); //IE} else {var subObj = tempForm.addEventListener("submit", function () {}, false); //firefox}document.body.appendChild(tempForm);if (document.all) {tempForm.fireEvent("onsubmit");} else {tempForm.dispatchEvent(new Event("submit"));}tempForm.submit();//提交POST请求document.body.removeChild(tempForm);//删除整个form标签}
700字范文,内容丰富有趣,生活中的好帮手!