views:

26

answers:

0

Hello,

I am trying to replace the default login slip which drops down when the user tries to access a page which needs HTTP Digest authentication.

I'm trying to achieve this with jQuery.

Below is a snippet of my code:

$.ajax({
    url: url,
    method:'GET',
    async:false,
    beforeSend:function(req) {
        req.setRequestHeader('Authorization','Digest ...');
    },
    success: function(x,y,z) {
               if(z.status == 200)
                 document.location = gohere;
    },
    error: function(a,b,c){
        if (a.status == 401) {
                alert('error 401:' + a.getAllResponseHeaders() + '|' + b + '|' + c);
        }
    }
});

Everything was fine till I try to redirect the user to the page which requires login - the slip still drops down although I got a successful response!

To make sure it wasn't the server's problem I logged in using the default web browser form and that worked fine.

So my question is there something wrong with my code? something missing that I need to include?

Thanks in advance