Skip to main content

Bug Tracker

Side navigation

#8719 closed bug (worksforme)

Opened March 31, 2011 01:43AM UTC

Closed April 01, 2011 02:52AM UTC

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:
Description

Environment

OS: Mac OSX 10.6.6

Browser: FF 3.1.16

Add-ons used in testing: Firebug 1.6.2, HTTPFox 0.8.8

Problem

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

HttpFox:

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

HttpFox:

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

Attachments (0)
Change History (3)

Changed March 31, 2011 03:52AM UTC by rwaldron comment:1

component: unfiledajax
owner: → 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?

Changed April 01, 2011 01:53AM UTC by jsguy comment:2

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.

Changed April 01, 2011 02:52AM UTC by rwaldron comment:3

resolution: → worksforme
status: newclosed