나는 비슷한 것을했습니다. 사용자가 버튼을 클릭하면
은 어떤 데이터를 전달 서버에 아약스 요청을 보내 :
$.ajax({
type: 'POST',
dataType: 'json',
url: '<%=Url.Action("GenerateReport", "MyController")%>',
data: { Param1: $('#Param1').val() , Param2: $('#Param2').val() },
beforeSend: function(xhr) {
$.blockUI({ message: '<h1> printing ...</h1>', css: { border: 'none', padding: '15px', backgroundColor: '#000', '-webkit-border-radius': '10px', '-moz-border-radius': '10px', opacity: .5, color: '#fff'} });
},
success: function(result) {
if (result.Success) {
FetchPdfDocument('<%=Url.Action("GetPdfReport", "MyController", New With {.id = "/"})%>' + result.Guid);
}
else {
alert("Problems!");
}
},
complete: function() {
$.unblockUI();
},
error: function(req, status, error) {
alert(error);
}
});
컨트롤러는 디스크에 문서를 작성하고 PDF 문서의 이름 GUID를 다시 보냅니다. I로드 피드백 표시기로 BlockUI jQuery를 사용한
function FetchPdfDocument(UrlToPdf)
{
$('#ifPdfReport').remove();
$(document.body).append('<IFRAME id="ifPdfReport" style="display:none;">');
$('iframe#ifPdfReport').attr('src', UrlToPdf);
// $('#ifPdfReport').load(function() { });
}
:
이것은 IFRAME을 생성하는 스크립트 파일을 열고 다른 비트이다. 도움이 되길 바랍니다.
아마 Ajax와 Json 응답이있는 컨트롤러를 사용하는 것이 가장 좋습니다. 처리하고 URL을 반환하자, 그 URL을 사용자에게 표시하십시오. –