2

Considering that I don't have a callback method defined before and the following code:

jQuery.ajax({
            url: 'url',
            type: 'GET',
            data: {},
            dataType: 'jsonp',
            crossDomain: true,
            jsonpCallback: callback,
            async: true,
            success: function ( pData ) {
                //process success
            },
            error: function (jqXHR, textStatus, errorThrown) {
                //Log error
            }
});

The jQuery is handling the ajax Events ( success/error ) properly, with no error. Why jQuery are doing that if in the API documentation is saying they can't do that? And sometimes I get parserror, but I'm always returning the same content as JSON.

Has anyone experienced this?

3
  • Where does the documentation say it can't do that? jsonp is why it works.... Commented Aug 8, 2013 at 20:01
  • 1
    you can't. jsonp requests do not trigger the error callback in recent versions of jQuery. I'm not entirely sure how previous versions handled it. This is the intended behavior. "Note: This handler is not called for cross-domain script and cross-domain JSONP requests." What version of jQuery are you using? Commented Aug 8, 2013 at 20:01
  • I'm using jQuery v1.6.1. I know that it's a old version, but is a environment limitation. Commented Aug 8, 2013 at 20:15

1 Answer 1

1

It depends on the type of error.

A parseerror may be catched(and will be catched )by jQuery when you use JSONP.(the documentation is not exact in this case)

But network-errors may not be catched, because JSONP does not make use of XMLHttpRequest, and therefore will not receive any status-codes that may indicate an error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.