title: Converting Curl GET request to Ajax
body: <p>I'm trying to replicate a Curl request to download a PDF in Ajax.  The Curl requests are explained in the PDF Filler docs <a href="http://developers.pdffiller.com/#api-client-libraries" rel="nofollow">here</a>.  The following Curl request successfully yields a response of the file content:</p>
  
  <pre><code>curl -X "GET" "https://api.pdffiller.com/v1/fillable_template/DOCUMENT_ID/download" -H "Authorization: Bearer API_KEY_FROM_STEP1"
  </code></pre>
  
  <p>I've tried the following Ajax:</p>
  
  <pre><code>$.ajax({
      method: 'GET',
      url: 'https://api.pdffiller.com/v1/fillable_template/DOCUMENT_ID',
      headers: {
        Authorization: 'Bearer API_KEY_FROM_STEP1',
      },
  })
  </code></pre>
  
  <p>Which yields the following error message:</p>
  
  <pre><code>Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
  </code></pre>
  
  <p>I've also tried xhr for the header, which also gives the same error:</p>
  
  <pre><code>$.ajax({
      method: 'GET',
      url: 'https://api.pdffiller.com/v1/fillable_template/DOCUMENT_ID',
      beforeSend: function(xhr) {
          xhr.setRequestHeader('Authorization', 'Bearer ' + 'API_KEY_FROM_STEP1');
          xhr.setRequestHeader('Accept-Language', 'en_US');
      },
  })
  </code></pre>
  
  <p>Any thoughts on where I'm going wrong?  Thanks!</p>