私のアプリケーションはMVC3、.netを使用して実装されています。ボタンをクリックするだけでExcelファイルを生成しようとしています。コントローラアクションの呼び出しは、Ajaxを使用して行われます。私の主な問題は次のとおりです。ファイルの生成中に、画面に画像を表示して、ユーザーに進行中の操作を知らせようとしています。画像は上手く表示できますが、操作終了後は非表示にできません。使用しているcodeiは:
Javascriptコード:
$("input.DownloadExcelReport").click(function (e) {
e.preventDefault();
var parameter = -- code to fetch parameter value;
var outputViewUrl = (the url is created here);
showLoading(); -- This function displays the image
window.location.href = outputViewUrl;
});
コントローラアクションコード:
public ActionResult DownExcelReportForAssortment(Guid parameter)
{
try
{
//the contents for the file generation are fetched here..
// Write contents to excel file
if (memoryStream != null)
{
var documentName = "Report.xls";
byte[] byteArrary = memoryStream.ToArray();
return File(byteArrary, "application/vnd.ms-excel", documentName);
}
}
catch (Exception ex)
{
LogManager.LogException(ex);
}
}
画像を非表示にするコードを記述できる呼び出し元のjavascriptメソッドにJsonの結果を返しません。ユーザーが保存できるファイルを返し、アクションが完了しました。
ファイル生成操作が完了したら、画像を非表示にするにはどうすればよいかを誰かに提案/助けてもらえますか?
ヘルプに感謝します...