利用JS使用POST方式提交请求的方法

来源:互联网 发布:ubuntu用户组权限设置 编辑:程序博客网 时间:2024/06/05 06:27
利用JavaScript模拟POST方式提交请求的方法
function post(URL, PARAMS) {            var temp = document.createElement("form");            temp.action = URL;            temp.method = "post";            temp.style.display = "none";    PARAMS =PARAMS ==null? {}:PARAMS;           for (var x in PARAMS) {                var opt = document.createElement("textarea");                opt.name = x;                opt.value = PARAMS[x];                // alert(opt.name)                temp.appendChild(opt);            }            document.body.appendChild(temp);            temp.submit();            return temp;        }                //调用方法 如        post('pages/statisticsJsp/excel.action', {html :prnhtml,cm1:'sdsddsd',cm2:'haha'});
阅读全文
0 0
原创粉丝点击