Bug Tracker

Opened 6 years ago

Closed 6 years ago

#8719 closed bug (worksforme)

getJSON fails too early on 407 header

Reported by: jsguy Owned by: jsguy
Priority: undecided Milestone: 1.next
Component: ajax Version: 1.5.1
Keywords: Cc:
Blocked by: Blocking:



OS: Mac OSX 10.6.6 Browser: FF 3.1.16 Add-ons used in testing: Firebug 1.6.2, HTTPFox 0.8.8


When using $.getJSON, in a proxied environment, you may get a 407 error, which means the proxy needs to be re-authenticated; when using $.ajax, this works fine (ie: there is no error called, and the 407 turns into a 200 after 1 second or so).

To replicate this, you will need a proxy server that can be setup to authenticate, unfortunately I don't have one to show you the error, so instead here is an example, and what I see in the firefox httpfox plugin and firebug:

getJSON - fails

var successFunc = function(r){ console.log("ok:", r); };

$.getJSON( urlThat407s, successFunc ).error( function( result ) {
    console.log( "err: ", result.status );

Firebug result:

err: 0


Result: 407 Type: text/html (NS_ERROR_DOM_BAD_URI)

ajax - this is ok, I'm using it as a temporary workaround

var successFunc = function(r){ console.log("ok:", r); };

$.ajax( {
    url: urlThat407s,
    dataType: "jsonp",
    cache: true,
    timeout: 30000,
    success: successFunc,
    error: function( result ) {
        console.log( "err: ", result.status );
} );

Firebug result:

ok: value from JSONP server


Result: 200 Type: text/html

Note: HttpFox briefly flashes the 407 error, before turning into a 200

What I was expecting

Ideally $.getJSON would be able to handle the 407 just like $.ajax does, however if it has to fail, (ie: you cannot make it work like $.ajax), then at least the status should be set to 407, rather than 0

Change History (3)

comment:1 Changed 6 years ago by Rick Waldron

Component: unfiledajax
Owner: set to jsguy
Status: newpending

There are two different things being attempted here - first to get json via $.getJSON (which will use XHR) and second to get JSONP via $.ajax (which does not use XHR). If the intent is to make a JSONP request, are you appending a the callback=? to the end of your $.getJSON url?

comment:2 Changed 6 years ago by jsguy

Status: pendingnew

Yes, it has callback=?, for the $.getJSON url, however it may be a problem with the proxy itself - I have since tested on a different proxy, and could not replicate the issue.

Can you please close this ticket, and once I find out what the problem is, I'll raise another.

comment:3 Changed 6 years ago by Rick Waldron

Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.