1

Will password-protecting a directory on a server that supports .htaccess interfere with an AJAX request? I have not encountered an error, but have also unlocked the domain on my end, meaning I've started a browser session.

Witch-King
  • 283
  • 1
  • 5
  • 13

1 Answers1

0

If a directory is password protected you need to provide credentials in order to access it.

The authentication is required only once per session so if the user was already logged in by viewing another page inside the same directory, ajax calls will succeed after viewing that page.

But if the user hasn't accessed any file inside this directory before and immediately sends an AJAX request to a file within it your AJAX request will fail unless you set the appropriate headers.

To see some examples have a look at How to use Basic Auth with jQuery and AJAX?

Community
  • 1
  • 1
Dany Khalife
  • 1,850
  • 3
  • 20
  • 47