title: How to get attachment file content with jQuery
body: <p>On a <code>get</code> response I have <code>content-disposition: attachment;filename=f.csv</code> and I need to download <strong>content</strong> of this file on the page .<br>
  On a <code>$.ajax</code> request I have an error.
  How can I get content of file using jQuery <code>ajax</code>(or <code>get</code>)?<br>
  <strong>UPD</strong></p>
  
  <pre><code>error: function( jqXHR, textStatus, errorThrown ) {
    console.log( jqXHR, textStatus, errorThrown );
  }  
  </code></pre>
  
  <p>get  </p>
  
  <pre><code>Object {
      ...
      readyState 0
      responseText ""
      status 0
      statusText "error"
  }, error,  
  </code></pre>
  
  <p><strong>UPD 2</strong><br>
  I found a <a href="https://github.com/johnculviner/" rel="nofollow noreferrer">jquery.fileDownload</a> plugin, but it shows browser's window with <em>save</em> or <em>open</em> dialog, like this:
  <img src="https://i.stack.imgur.com/Ss3ZK.png" alt="save/open dialog"><br>
  But I need to get <strong>file content</strong>.<br>
  I'm no need to download file on computer.  </p>
  
  <p><strong>UPD 3</strong><br>
  Full code listing:  </p>
  
  <pre><code>$.ajax( {
      url: link,
      crossDomain: true,
      dataType: "text",
      success: function( data, textStatus, jqXHR ) {
          alert( data );
      },
      error: function( jqXHR, textStatus, errorThrown ) {
          console.log( jqXHR, textStatus, errorThrown );
      }
  } );  
  </code></pre>
  
  <p>File generates by another service and I can't change it.<br>
  <strong>UPD 4</strong><br>
  First of all I'l try to get <code>json</code> data from another domain like this:  </p>
  
  <pre><code>$.ajax( {
      url: link,
      async: true,
      cache: true,
      dataType: "jsonp",
      crossDomain: true,
      type: "GET",
      jsonp: "finance_charts_json_callback",
      jsonpCallback: "finance_charts_json_callback",
      error: function( jqXHR, textStatus, errorThrown ) {
          console.log( jqXHR, textStatus, errorThrown );
      },
      success: function( data, textStatus, jqXHR ) {
          console.log( data );
      }
  } );  
  </code></pre>
  
  <p><code>link</code> looks like <code>http://chartapi.finance.yahoo.com/instrument/1.0/a/chartdata;type=quote;ys=2012;yz=2;ts=1234567890/json?finance_charts_json_callback=finance_charts_json_callback</code>  </p>
  
  <p>And it's response headers:  </p>
  
  <pre><code>HTTP/1.1 200 OK
  Date: Wed, 30 Apr 2014 12:01:08 GMT
  P3P: policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO ... GOV"
  Cache-Control: public
  Expires: Thu, 01 May 2014 00:32:18 GMT
  Last-Modified: Wed, 30 Apr 2014 00:32:18 GMT
  Content-Type: text/javascript; charset=utf-8
  Content-Encoding: gzip
  Vary: Accept-Encoding,X-Ssl
  Age: 0
  Via: http/1.1 yts39.global.media.ir2.yahoo.com (...)
  Server: ATS
  Connection: keep-alive  
  </code></pre>
  
  <p>All works fine.  </p>
  
  <p>When I try to get file from another server there it's response headers:  </p>
  
  <pre><code>HTTP/1.1 200 OK
  Cache-Control: no-cache
  Date: Wed, 30 Apr 2014 12:09:01 GMT
  Pragma: no-cache
  Content-Type: text/csv
  Expires: -1
  Server: Microsoft-IIS/6.0
  X-Powered-By: ASP.NET
  X-AspNet-Version: 2.0.50727
  content-disposition: attachment;filename=export.csv
  Content-Encoding: gzip
  Vary: Accept-Encoding
  </code></pre>