ppazos / cabolabs-ehrserver-js

Javascript client for EHRServer
Apache License 2.0
8 stars 6 forks source link

Process JSONP errors #1

Open ppazos opened 9 years ago

ppazos commented 9 years ago

http://jsfiddle.net/chufol/SrQqP/

http://stackoverflow.com/questions/19035557/jsonp-request-error-handling https://forum.jquery.com/topic/jquery-ajax-with-datatype-jsonp-will-not-use-error-callback-if-request-fails http://stackoverflow.com/questions/4281274/jquery-ajax-404-handling

http://stackoverflow.com/questions/5388934/jquery-handle-errors-in-getjson http://stackoverflow.com/questions/19164273/jquery-getjson-error-handling http://stackoverflow.com/questions/1740218/error-handling-in-getjson-calls

http://api.jquery.com/jquery.getjson/ (see last example, fail is not triggered...)

ppazos commented 9 years ago

The problem with JSONP is that the server responds 404 means that it will not retrieve any javascript so the response body is empty in the browser, even if the server returns the error in JSON.

Test this plugin: https://github.com/jaubourg/jquery-jsonp And this sample: http://stackoverflow.com/questions/19035557/jsonp-request-error-handling/19185826#19185826