Jquery .submit()回调以关闭加载模式

时间:2021-10-16 11:36:36

i have my controller that returns a PDF (i'm using Framework Rotativa PDF). Using ajax is not possible to make my request. So, i need a callback to close my loading modal after processing the request and returned because the same request can be long.

我有我的控制器返回PDF(我正在使用Framework Rotativa PDF)。使用ajax无法提出我的请求。因此,我需要一个回调来处理请求后关闭我的加载模式并返回,因为相同的请求可能很长。

CONTROLLER

public ActionResult DownloadViewPDF()
{
   var model = new GeneratePDFModel();
   //Code to get content
   return new Rotativa.ViewAsPdf("GeneratePDF", model){FileName = "TestViewAsPdf.pdf"}
}

MY FORM

<form id="myform" method="post" enctype="multipart/form-data" action="@Url.Content("/PDF/DownloadViewPDF/")">
   <input type="text" name="myparameter" />
</form>

<button id="sendForm" value="OK"></button>

JAVASCRIPT

$('#sendForm').on('click', function () {
    $('#loadingModal').modal('show');
    $('#myform').submit();
    //after i need close this modal
});

1 个解决方案

#1


0  

You can try and chain these events together so one event fires off the next if AJAX is out of the question.

您可以尝试将这些事件链接在一起,以便在AJAX不可能的情况下触发下一个事件。

$( "#sendForm" ).click(function(e) {
   e.preventDefault();
   $('#myform').submit();
});

$("#myform").submit(function( event ) {
  //close dialog here
});

#1


0  

You can try and chain these events together so one event fires off the next if AJAX is out of the question.

您可以尝试将这些事件链接在一起,以便在AJAX不可能的情况下触发下一个事件。

$( "#sendForm" ).click(function(e) {
   e.preventDefault();
   $('#myform').submit();
});

$("#myform").submit(function( event ) {
  //close dialog here
});