html js POST提交跳转页面

/**
 * 采用post方式跳转
 * @param URL
 * @param PARAMS json格式数据 {html :prnhtml,cm1:'测试',cm2:'haha'}
 * @returns {Element}
 */
function post(URL, PARAMS) {
    var temp = document.createElement("form");
    temp.action = URL;
    temp.method = "post";
    temp.style.display = "none";
    for (var x in PARAMS) {
        var opt = document.createElement("textarea");
        opt.name = x;
        opt.value = PARAMS[x];
        temp.appendChild(opt);
    }
    document.body.appendChild(temp);
    temp.submit();
    return temp;
}

猜你喜欢

转载自blog.csdn.net/zj420964597/article/details/81207311