Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

jQuery ajax error handlers usage issue #15

Open
tommiv opened this issue Feb 4, 2015 · 0 comments
Open

jQuery ajax error handlers usage issue #15

tommiv opened this issue Feb 4, 2015 · 0 comments

Comments

@tommiv
Copy link

tommiv commented Feb 4, 2015

Hi. The error handlers on lines 251, 303, 332

error: settings.onError.call(container, externalUrl, embedProvider)

will be executed immediately, before ajax even started, since call is imperative to execute function right now. Then call will return undefined. As result, it will allways be errors in console, even when ajax succeed and no error handler will assigned to ajax at al. Right approach is to wrap handler code into anonymous function like

error: function(xhr, type, httpcode) {
    settings.onError.call(container, externalUrl, embedProvider, type, httpcode);
}

or to make settings.onError allways return function which does something with arguments.

But both of this methods will not help actually, because most of the library calls are JSONP, which is not ajax. According to jQuery manual

Note: This handler is not called for cross-domain script and cross-domain JSONP requests. This is an Ajax Event.

There is not much we can do about error handling in JSONP – fall gracefully after timeout exceeded is the limit. More info in SO question.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant