$(function () { function loadSectionHtml(sectionsData) { var loadHtmlArr = [ // "cover", //封面 // "preface", //前言 // "section_1", "section_2", // "section_3", // "section_4", ]; $(".pdf_root").html(loadHtmlArr.map(function (htmlName) { return "
"; }).join("")); loadHtmlArr.forEach(function (htmlName) { // 考试概况ksgk, 成绩分析cjfx, 成绩分析-等级分析djfx, 违纪分析wjfx, 优秀试卷yxsj if (htmlName === "preface") { $("." + htmlName + "_html_root").data("page-params", JSON.stringify(sectionsData)); } else if (htmlName === "section_1") { $("." + htmlName + "_html_root").data("page-params", JSON.stringify(sectionsData.ksgk)); } else if (htmlName === "section_2") { $("." + htmlName + "_html_root").data("page-params", JSON.stringify({ cjfx: sectionsData.cjfx, djfx: sectionsData.djfx })); } else if (htmlName === "section_3") { $("." + htmlName + "_html_root").data("page-params", JSON.stringify(sectionsData.wjfx)); } else if (htmlName === "section_4") { $("." + htmlName + "_html_root").data("page-params", JSON.stringify(sectionsData.yxsj)); } $("." + htmlName + "_html_root").load("../sections/" + htmlName + ".html"); }); } $.ajax({ type: "POST", url: _sexam_ers_pdf, data: JSON.stringify({ examid: 2 }), dataType: "json", contentType: "application/json; charset=utf-8", success: function (data) { if (data.code === 0) { loadSectionHtml(data.obj); } else { alert(data.msg); } } }); });