Skip to content

success callback fired twice in ajax method #91

@bretdavi

Description

@bretdavi

When passing in a data object, that contains 'url', to the ajax method it extends the params object with the data.

The issue is when 'data' includes a success callback function. The params passed to $.ajax internally include this success function, yet later the success function also gets called in the ok() method, which is called by the done() method.

So the result is my success function firing twice whenever I call eModal.ajax()

It also looks like the error() method suffers the same issue as well, though I was only troubleshooting the success issue

Below is the pertinent code I'm referring to in the ajax method:

           if (data.url) {
                $.extend(params, data);
            }

            $.ajax(params)
                .done(ok)
                .fail(error);

            return alert(params, title);

            function ok(html) {
                $modal
                    .find('.' + MODAL_BODY)
                    .html(data.success ? data.success(html) : html);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions