【发布时间】:2011-09-27 16:25:00
【问题描述】:
基本上问题是这样的:
我有一个基于当前登录用户 ID 和 OID 从服务器请求的 pdf 文件。为了获取 OID,我必须根据用户单击的按钮从 HTML 表中解析一个值,然后将其发送到家庭控制器。然后运行 API 调用来获取 OID。然后使用 OID 进行另一个 API 调用以提取 PDF 文件。 AJAX 用于将解析后的 HTML 值发送到主控制器,这里使用以下代码:
$('.pdfPrint').live('click', function () {
$(this).addClass('selectedDetails');
var parent = $('.selectedDetails').parents('tr');
var tr = $(this).parents('tr');
var td = tr.children();
var i = 0;
td.each(function () {
$(this).addClass('tdGrid' + i);
i++;
});
var primaryReference = "";
primaryReference = $('.tdGrid1').text();
gridClassRemover();
$.ajax({ // create an AJAX call...
data: { pReference: primaryReference }, // get the form data
type: "POST", // GET or POST
url: "/Home/PrintFromGrid", // the file to call
success: function (response) { // on success..
callTrackDialog();
// update the DIV
}, // end of success
error: function () {
alert('An error has occurred. If this problem persists please contact support.');
}
}); // end of .ajax
});
【问题讨论】:
-
看看我的帖子我做到了。stackoverflow.com/questions/11550301/…
标签: ajax asp.net-mvc-3 pdf download