Jquery 使用PDF从ajax结果加载嵌入控件
我有一个DIV里面有一个奖励ID,我有一个嵌入Jquery 使用PDF从ajax结果加载嵌入控件,jquery,html,embed,Jquery,Html,Embed,我有一个DIV里面有一个奖励ID,我有一个嵌入 <div id="award"> <embed src="" width="400" height="500"> </div> AJAX调用是 var fileName = context.Request["FileName"]; var storageConnectionString = System.Configuration.ConfigurationManager.AppSettings[
<div id="award">
<embed src="" width="400" height="500">
</div>
AJAX调用是
var fileName = context.Request["FileName"];
var storageConnectionString = System.Configuration.ConfigurationManager.AppSettings["BlobStorageConnectionString"];
var blobContainerName = System.Configuration.ConfigurationManager.AppSettings["BlobStorageContainerName"];
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(blobContainerName);
CloudBlockBlob blockBlob2 = container.GetBlockBlobReference(fileName);
blockBlob2.FetchAttributes();
long fileByteLength = blockBlob2.Properties.Length;
Byte[] myByteArray = new Byte[fileByteLength];
blockBlob2.DownloadToByteArray(myByteArray, 0);
context.Response.ContentType = "application/pdf";
context.Response.AddHeader("Content-Length", myByteArray.Length.ToString());
context.Response.AppendHeader("content-disposition", "inline; filename=" + fileName);
context.Response.BinaryWrite(myByteArray);
context.Response.End();
这就是我失败的地方。。。。
我能够在警报中看到PDF文档字节数组
如何用AJAX调用的结果填充嵌入
我假设这条线
$("#target embed").body.update(display.data);
这是我需要执行操作的地方,但我不知道如何真正完成它。解决了-
success: function (data) {
$("#target embed").attr("src", "handlers/loadPDFHandler.ashx?fileName=Bid" + record + ".pdf");
// alert(data);
// $("#target embed").body.update(display.data);
success: function (data) {
$("#target embed").attr("src", "handlers/loadPDFHandler.ashx?fileName=Bid" + record + ".pdf");
// alert(data);
// $("#target embed").body.update(display.data);