我正在做ajax POST:
$.ajax({
type: 'POST',
url: rootUrl("Home/PrintInvoice/12"),
success: function (result) {
$("#TestInvoicePrint").empty();
$("#TestInvoicePrint").html(result);
window.open(result);
}
});
我在MVC操作的结果中获取PDF文件,
public ActionResult PrintInvoice(long ID)
{
var data = db.Documents.Where(x => x.InvoiceNumber == ID);
ReportDocument rd = new ReportDocument();
rd.Load(Server.MapPath("~/Reports/InvoiceDocument.rpt"));
ConnectionInfo ConnInfo = new ConnectionInfo { ServerName = "10.0.0.154,1433\\sqlexpress", UserID = "CueReader", Password = "CueReader@123", DatabaseName = "Cue" };
ParameterFieldDefinitions parmFields = rd.DataDefinition.ParameterFields;
ParameterValues pvals = new ParameterValues();
rd.ParameterFields["DocumentID"].CurrentValues.IsNoValue = true;
Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, SeekOrigin.Begin);
return new FileStreamResult(stream, "application/pdf");
}
如何从ajax POST将PDF文件用于我的DOM元素?
答案 0 :(得分:0)
如果你能让ajax给你一个url(动态?)然后更新一个对象data = attribute
会更好