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

jQuery ajax error handlers usage issue #15

Open
@tommiv

Description

@tommiv

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions