2012-10-23 49 views
0

我需要運行下載,然後繼續執行代碼?我將如何去做這件事?開始下載鏈接? JQuery或C#

此功能正在檢查文件何時下載到我的服務器上,然後我需要運行下載到我的客戶端計算機,女巫是我在哪裏嘗試window.open(「url」)。

function checkSpreadsheetProgress(taskId, filename) { 
     var intervalId2 = setInterval(function() { 
      $.post("SpreadSheetProgress", { id: taskId }, function (SpreadSheetProgress) { 
       if (SpreadSheetProgress >= 100) { 
        clearInterval(intervalId2); 
        window.open("http://formvalue.co.za/download/" + filename + ".xlsx") 
    //The line above is my attempt at running the download link but it did nothing? 
    //The line below pushes me to my Downloadcompleate action result. 
        window.location.href = "downloadcomplete?filename=" + filename; 
       } else { 

       } 
      }); 
     }, 100); 
    } 

我可以下載使用C#中的文件,但不能繼續後面我重定向方法的代碼。

public ActionResult DownloadComplete(string filename) 
{ 
    //return Redirect("http://formvalue.co.za/download/" + filename + ".xlsx"); 
    // The above line will download the file but then i cant return a view? 
    return View(); 
} 
+1

爲什麼'window.open(「」...「」)'中的四重引號? –

+0

對不起我的壞它不像我的代碼只是在我的問題,如果編輯,感謝您的錯誤 – Pomster

+2

你的意思是你真的想要等到下載完成之前繼續?如果是這樣,我不認爲這是可能的。 – Rawling

回答