title: Basic Auth with Jquery and Ajax
body: <p>I try to get access to a directory or file that is protected with .htaccess with this code:</p>
  
  <pre><code>        function make_base_auth(user, password) {
        var tok = user + ':' + password;
        var hash = btoa(tok);
        return "Basic " + hash;
      }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>            $.ajax
            ({
              type: "GET",
              url: "prot/index.php",
              dataType: 'json',
              async: false,
              data: {username: username, password: password},
              headers  : { Authorization: make_base_auth(username, password) },
              success: function (){
                  alert('geschafft'); 
              },
              error: function (xhr, ajaxOptions, thrownError){
                  console.log('Fehler: ' + thrownError+ "; status:  " +xhr.status);
              } 
          });
  </code></pre>
  
  <p>But I get the error: </p>
  
  <blockquote>
    <p>SyntaxError: Unexpected end of input
    and the status 200</p>
  </blockquote>
  
  <p>I also tried it with beforeSend and xhr.SetRequestHeader with the same result.</p>
  
  <p>What's wrong ?</p>