1

post请求方式

模拟form表单提交的方式

openPostWindow = function (exportparams) {
    var form = $("<form>");//定义一个form表单
    form.attr("id", "downloadform");
    form.attr("style", "display:none");
    form.attr("target", "_blank");
    form.attr("method", "post");
    form.attr("action", "/EXPORT/user/change-history.json");
    var input1 = $("<input>");
    input1.attr("type", "hidden");
    input1.attr("name", "param");
    input1.attr("value", JSON.stringify(exportparams));
    form.append(input1);
    $("body").append(form);//将表单放置在web中

    form.submit();//表单提交
    $("#downloadform").remove();
}

get请求方式

function exportInfo() {
    var params = getParams();
    delete params.pageDto;
    delete params.userName;
    window.open('/EXPORT/leaveInfo/list.json?' + $.param(params), '_blank');
}

Snoopy
19 声望2 粉丝