title: JavaScript redirect URL with Authorization header
body: <p>I managed to successfully invoke a URL behind a directory in Apache that is protected with Basic Authentication (htpasswd, etc.). The Ajax GET request works normally and returns the protected content:</p>
  
  <pre><code>var encoded = Base64.encode(username + ':' + password);
  $.ajax({
      url: "/app/test",
      type: "GET",
      beforeSend: function(xhr) {
          xhr.setRequestHeader('Authorization', 'Basic ' + encoded);
      },
      success: function() {
          window.location.href = '/app/test.html';
      }
  });
  </code></pre>
  
  <p><strong>My original assumption was that once the web session had successfully authorized a request, it would make possible the redirection in the 'success' block without asking user credentials</strong>. When this code block is invoked, the user had entered username and password, in a non-protected environment. However, when the redirect is invoked, the browser will popup the the login/password window.</p>
  
  <p>Any suggestions on how I could pre-authorize a session with the Basic Authorization which would have been provided by the users?</p>