title: Cannot return a laravel download via ajax call
body: <p>I want the user to download a file and it doesn't really need to be via ajax, but it was the easiest way I found, but it's not working.</p>
  
  <p>Here is my method from the Controller that I'm calling:</p>
  
  <pre><code>  public function download(Request $request) 
    {
        $dir = $request-&gt;get("directory");
        return response()-&gt;download($dir);
    }
  </code></pre>
  
  <p>Here is my ajax function:</p>
  
  <pre><code>function download(diretorio) {
  
      $.ajax({
        url: "/panel/download",
        data: {_token: jQuery(".token").val(), diretorio: diretorio},
        success: function(e) {
  
        }
      }).done(function(e) {  
  
      });
  }
  </code></pre>
  
  <p>This function is being called inside this append:</p>
  
  <pre><code>$('#uploads tbody').append("&lt;tr&gt;&lt;td&gt;" + fileName + "&lt;/td&gt; &lt;td&gt;&lt;a class='btn btn-success' href='' onclick=\"download('" + item + "')\"&gt;Download&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt;");
      });
  </code></pre>
  
  <p>Here is my route, which is inside a group called panel:</p>
  
  <pre><code>Route::get('/download/', ['as' =&gt; 'files.download', 'uses' =&gt; 'Panel\ClientController@download']);
  </code></pre>
  
  <p>My first question is: Is it possible to make this call from ajax to a download response from laravel?</p>
  
  <p>Second question: I cannot figure out how to replace the ajax call for a route to a laravel controller, is it possible?</p>
  
  <p>Thank you!</p>