Today I had some difficulty in checking the existence of a jsonp file. Turns out that jsonp doesn’t return a traditional ajax 404 error if the file doesn’t exist. So I wrote a nifty hack to get around it.

The important parts are to only do a HEAD lookup or you will grab the entire file, be sure to set a timeout (especially in the instance of jsonp, which as I mentioned, won’t return a traditional 404) and be sure to set your dataType correctly.

The code:

Or see it in action on jsFiddle.