【发布时间】:2016-09-16 08:02:17
【问题描述】:
GetDataStudentPDF() 调用 webmethods 并获取项目列表,每个项目都是一个 html 脚本。我只想将该脚本设置为 div,然后调用另一个 SaveImage() 函数,该函数将 div 转换为图像并保存它。每个项目都应该发生这种情况
function SaveImage(i, lastI) {
$('#divStdTemplate').html2canvas({
onrendered: function (canvas) {
var img = canvas.toDataURL("image/png").replace(/^data[:]image\/(png|jpg|jpeg)[;]base64,/i, "");
$.ajax({
type: "POST",
url: "SliderPage.aspx/StudentPopUpUploadImage",
data: JSON.stringify({ imageData: img }),
contentType: "application/json; charset=utf-8",
dataType: 'json',
async: false,
success: function (response) {
},
failure: function (response) {
alert("html2canvas Fail");
},
error: function (response) {
alert("html2canvas Error * " + response.error + " * " + response.responseText);
}
});
}
});
}
function GetDataStudentPDF()
{
var cnt1 = 0;
$.ajax({
type: "POST",
url: 'SliderPage.aspx/GetDataStudentPDF',
data: JSON.stringify({}),
contentType: "application/json; charset=utf-8",
dataType: 'json',
async: true,
success: function (response) {
var data = response.d;
$.each(data, function (index, item) {
$("#divStdTemplate").html(item);
SaveImage();
});
},
failure: function (response) {
alert("Fail");
},
error: function (response) {
alert(response);
}
});
}
【问题讨论】:
标签: jquery c#-4.0 asp.net-ajax