In my controller I have an ActionResult
which returns a File.
[HttpPost]
public ActionResult ExportCSV(ReportResultViewModel model)
{
var content = "hello,world";
return File(Encoding.UTF8.GetBytes(content),"text/csv","export.csv");
}
In my view, when I post to this ActionResult, I display a modal saying "please wait".
<!-- language: lang-html --><!--modal-->
<div class="modal fade" id="pleaseWaitDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content" style="background: #EBF3EB;">
<div class="modal-header">
<h1>Please wait...</h1>
</div>
<div class="modal-body">
<div id="loader"></div>
</div>
</div>
</div>
</div>
@using (Html.BeginForm("ExportCSV", "Reporting", FormMethod.Post, new { name = "back", id = "back", style = "width:100%" }))
{
@Html.HiddenFor(m => m.A)
@Html.HiddenFor(m => m.LOT)
@Html.HiddenFor(m => m.OF)
@Html.HiddenFor(m => m.THINGS)
<input type="submit" data-toggle="modal" data-target="#pleaseWaitDialog" value="Export CSV" style="width: 100%; background: #fff" class="btn btn-default" />
}
I want to hide it when the file is finally returned to the page.
Is there a way to detect client side (with JavaScript maybe) when the file arrives so I can hide the modal?