JSONP with Error Checking
At a previous job I had a project where I needed to retrieve data from YouTube and Vimeo. While YouTube always returns data even with an invalid video id, the Vimeo script element returns a 404 Not Found error on an invalid video ID. The jQuery version of JSONP does not support error handling and I needed to tell the user that an error had occured.
JSONP is a method of getting cross domain data using the browser by injecting a script element that points to a cross domain source and passing in the URL query string the name of a callback function. The script element calls the callback function with the passed data as the function argument. You could make a call like:
http://tanny.ica.com/ICA/TKO/test.nsf/jsondoc.js?unid=B933790B1DC265ED8025725800728CC5&callback=dir.showDoc
Which would return:
dir.showDoc({ "firstname":"Adam", "middleinitial":"", "lastname":"Aaron", "fullname":Adam Aaron/ROCKALL, "shortname":"AAaron", "unid":"B933790B1DC265ED8025725800728CC5" });