How to programatically access a password protected website?

.htaccess, ajax, passwords, web-services

Solution

Basic HTTP authentication:

http://coderseye.com/2007/how-to-do-http-basic-auth-in-ajax.html

Problem

Part of our website is protected with .htaccess style password protection. When you try to access this area of the website the web browser pops up a dialog asking for your username and password. I need to access this programatically (eg with an ajax call). How does the server tell me it needs a password and how do I supply it?

Original source