I think this is a known limitation of jsonp as a technique, not a bug
with jquery itself. Jsonp works by appending a script tag to the DOM,
whose "src" attribute points to the URL you specify. The URL is
expected to wrap a json object in a function call to the function you
specify, and the returned text is evaluated using eval().. Just like
script tags that are returned in the sorce HTML, if the server doesn't
respond (or throws a 404), I don't think there is a way to determine
that through JavaScript.

$.ajax() can determine other error scenarios by inspecting the XHR
object, but jsonp doesn't use XHR. Hope that helps.

On Oct 1, 12:18 pm, mrandall <randall...@gmail.com> wrote:
> I'm using an .ajax() call to do a jsonp request to another domain.
> When the user is not logged in, however, the server will return a 401
> error.  Unfortunately, this causes my .ajax() call to fail _without_
> calling the error callback.  Is this a known bug?  Here is my code:
>
>       $.ajax({
>         url:      appData.API.workout.get,
>         data:     {date: App.formatDate(date)},
>         dataType: 'jsonp',
>         success:  function(json) {
>           Data =  json;
>           model.buildOrderedWorkout();
>           myCP.Workout.View.initialize();
>         },
>         error:    function(xOptions, error) {
>
>           Controller.requestError(xOptions, error);
>         }
>       });
>
> Is there a way to get this request to not fail?  I also looked at the
> jquery-jsonp plugin, but that didn't really work and did not return
> the http status codes.
>
> Thanks for your help,
> Mike

Reply via email to