XMLHttpRequest and apache HTTP authentication

M

marcroy.olsen

Hi List,

I'm a newbie javascritp haxer, but i'm tryning to make a AJAX app.
I have make the backend on a Apache server and usinging the apache
HTTP mod_auth_bacis(http://httpd.apache.org/docs/2.2/mod/
mod_auth_basic.html) over SSL to talk to my webservice.
This all works fin.

Then in my javascript I use the XMLHttpRequest to call the webservice
like this:
***************************************************************************************************
httpRequest = new XMLHttpRequest(); //only using mozilla
httpRequest.onreadystatechange = function() {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
return httpRequest.responseXML;
}
else{
return "error"
}
}
httpRequest.open('GET', url, false, username, password);
httpRequest.send('');
***************************************************************************************************
This works if the password and usernam is right(from a input in the
javascript). But if the username or password is wrong the browser
promt me for at username and password.
How do I catch that so the browser don't ask for a username and
password. But presentes the login page again?

Best regards

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top