6

Conclusion: fast response by Kevin enables the JSONP functionality of the API to assume it's rightful description of awesome.

http://soapi.info/Code/JS/Stable/ErrorTest.htm


The JSONP functionality is great, but implementation differences between browsers severely cripple any efforts to respond to error conditions. In most browsers, a non 200 will not result in injection of the response text.

Notice that JQuery does not support error callbacks for JSONP. The only way to assume an error is to use a timeout.

See SOAPI-EXPLORE for an example. Input bogus params and submit - no return.

If, when JSONP is specified, the API would send the error json with a 200 we could receive the error and respond appropriately.

There is no way to reliably receive a JSONP result with an http status != 200, rendering the JSONP functionality of the API unreliable.

Demonstration

http://soapi.info/Code/JS/Stable/ErrorTest.htm

Results:

  • WebKit (Chrome, Safari): the browser passes the response and we can examine the jsob to determine whether it is an error.

  • IE, Opera, Firefox: no result. dead. only option is to implement a timeout.

UPDATE:

WebKit only lets the 500 error through. 404 and the 4000's are all swallowed by the browser, making the case for a 200 status for jsonp errors.

1
  • 1
    I agree - especially because my JavaScript wrapper uses jsonp too. Jun 10, 2010 at 5:32

1 Answer 1

2

Done.

Compare:
http://api.stackoverflow.com/0.8/errors/4002
and
http://api.stackoverflow.com/0.8/errors/4002?jsonp=wrapperFunc

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .