title: Return File Not Working When Calling Controller Via AJAX
body: <p>I'm trying to download an image via <code>ajax</code>using <code>&lt;a&gt;</code>. This is my code to populate my <code>DataTable</code>.</p>
  
  <pre><code>$.ajax({
      url: "/Capability/GetAllTrainingLog",
      type: "GET",
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: function (data) {
          $("#tblTrainingLog").dataTable({
              data: data,
              columns: [
              {'data' : 'TrainingTitle'},
              {'data' : 'TrainingURL'},
              {"data": null, render: function (data, type, row) {
                  //data.attachment returns a file path e.g C:\Project\App_Data\image.jpg
                  return '&lt;a onclick="fncDownloadImage(\''+ data.Attachment.replace(/\\/g,"\\\\") +'\')" &gt;Download&lt;/a&gt;'
              }}
          }
          ]
      });
      },
      error: function (XMLHttpRequest, textStatus, errorThrown) {
          alert("A problem has been encountered. Please contact the web administrator.");
      }
  })
  </code></pre>
  
  <p>Here is the code for the <code>fncDownloadImage</code> function:</p>
  
  <pre><code>function fncDownloadImage(fileName)
  {
          var download = {'filePath' : fileName}
          $.ajax({
          type: "POST",
          url: '/Capability/Download',
          data: JSON.stringify(download),
          dataType: 'json',
          contentType: 'application/json; charset=utf-8',
          success: function (response) {
              alert('Success');
          },
          error: function (XMLHttpRequest, textStatus, errorThrown) {
              alert(errorThrown);
          }
      });
  }
  </code></pre>
  
  <p>And the code to the <code>/Capability/Download</code> Controller:</p>
  
  <pre><code>[HttpPost]
  public FileResult Download(TrainingModel pass)
  {
      byte[] fileBytes = System.IO.File.ReadAllBytes(pass.filePath);
      string fileName = Path.GetFileName(pass.filePath);
      return File(pass.filePath, System.Net.Mime.MediaTypeNames.Application.Octet, Path.GetFileName(pass.filePath));
  }
  </code></pre>
  
  <p>When I execute the <code>fncDownloadImage</code> the controller doesn't return an error but the <code>fncDownloadImage</code> function returns an error: <code>SyntaxError: Unexpected token in JSON at position 0</code>.</p>
  
  <p>What is the problem with my code?</p>