Hide image using Javascript after controller action is complete MVC3

Viewed 4001

My application has been implemeted using MVC 3, .net. I am trying to generate an excel file at the click of a button. The call to the controller action is made using Ajax. My main problem is: During the file generation i am trying to display an image on the screen to let the user know of the ingoing operation. I can very well display the image but i cannot hide it after the operation is completed. The codei am using is :

Javascript code:

$("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;
});

Controller Action code:

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);
       }
}

I do not return a Json result to the calling javascript method where i can write the code to hide the image. I am returning a file which can be saved by the user and the action is completed.

Can somone please suggect/help me of how can i hide the image once the file generation operation is complete?

Appreciate the help...

1 Answers
Related