views:

148

answers:

1

I am executing the following jquery ajax call to an asp.net mvc controller which works, however on the firebug console it seems it is getting executed three times. The first two times it returns 401 Unauthorized and the final time it return 200 Ok. Could anyone shed some light on what is happening when I make this request and how I could stop the inital calls from failing.

$.ajax({
    type: 'POST',
    url: '/Core/GetVariableSet',
    dataType: 'json',
    data: {},
    success: function(response) {
        thisObject.Date = new Date(response.Date);
        thisObject.UserId = response.UserId;
        thisObject.UserName = response.UserName;
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
        Util.errorhandling.AJAXError($('#main'), 
                       'Error Getting Variables',
                       XMLHttpRequest, 
                       textStatus, 
                       errorThrown);
    }
});
A: 

Difficult to say with out the context in which it is being executed. I.e. when the executions are done, and why it excutes three times.

The fact that it is being tried until the 200 is received makes me suspect that there is some sort of rety going on. Possibly something hasn't finished loading?

Have a read about the 401 error to see if this sheds any light on it for you.

http://www.checkupdown.com/status/E401.html

James Wiseman