<p>Is it possible to catch an error when using JSONP with jQuery? I've tried both the $.getJSON and $.ajax methods but neither will catch the 404 error I'm testing. Here is what I've tried (keep in mind that these all work successfully, but I want to handle the case when it fails):</p>

<pre><code>jQuery.ajax({
    type: "GET",
    url: handlerURL,
    dataType: "jsonp",
    success: function(results){
        alert("Success!");
    },
    error: function(XMLHttpRequest, textStatus, errorThrown){
        alert("Error");
    }
});
</code></pre>

<p>And also:</p>

<pre><code>jQuery.getJSON(handlerURL + "&amp;callback=?", 
    function(jsonResult){
        alert("Success!");
    });
</code></pre>

<p>I've also tried adding the $.ajaxError but that didn't work either:</p>

<pre><code>jQuery(document).ajaxError(function(event, request, settings){
   alert("Error");
});
</code></pre>

<p>Thanks in advance for any replies!</p>

It seems that JSONP requests that don't return a successful result never trigger any event, success or failure, and for better or worse that's apparently by design.
After searching their bug tracker, there's
a patch
which may be a possible solution using a timeout callback.  See
bug report #3442
.  If you can't capture the error, you can at least timeout after waiting a reasonable amount of time for success.