下载excel文件时,url过长无法正常请求时。通过form提交来作post请求

 var tempForm = document.createElement("form");
        tempForm.id = "tempForm1";
        tempForm.method = "post";
        tempForm.action = url;
        tempForm.target = "_self"; //不打开新页面
        var hideInput1 = document.createElement("input");
        hideInput1.type = "hidden";
        hideInput1.name = "data"; //后台要接受这个参数来取值
        hideInput1.value = data; //后台实际取到的值
        tempForm.appendChild(hideInput1);
        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();
        document.body.removeChild(tempForm);

上一篇:jquery验证表单 提交表单


下一篇:jquery-validation - 05 -其他设置