2012-12-10 20 views
0

我試圖使用Ajax jquery調用來觸發Firefox上的下載彈出框。 我jQuery代碼是這樣的:如何使用Rails 3觸發下載彈出框

function download_clip(){ 
    $.ajax({ 
     url: '/controller/download_clip', 
     type: "GET", 
     complete: function (data_response) { 
      status = data_response.responseText; //the response variable from the presentation controller 
      console.log(status); 
     } 
    }); 
}; 
在我的控制器

def download_clip 
     send_file "public/output.mp4", :type=>"video/mp4", :filename => "output.mp4", :x_sendfile=>true, :disposition => 'inline' 
    end 

任何想法如何觸發下載框?

回答

0

...好,我覺得火狐如果你

document.location.href = "/controller/download_clip"; 

用JavaScript本身做到這一點。