framework7 icon indicating copy to clipboard operation
framework7 copied to clipboard

Добавить error handler для методов get, post, getJSON

Open softexe opened this issue 10 years ago • 1 comments

Error требуется для построения полноценного promise объекта с использованием перечисленных методов.

Сейчас используется такой фикс //niko

       // Shrotcuts
        (function () {
            var methods = ('get post getJSON').split(' ');
            function createMethod(method) {
                $[method] = function (url, data, success, error) {
                    return $.ajax({
                        url: url,
                        method: method === 'post' ? 'POST' : 'GET',
                        data: typeof data === 'function' ? undefined : data,
                        success: typeof data === 'function' ? data : success,
                        error: typeof data === 'function' ? success : error, //niko
                        dataType: method === 'getJSON' ? 'json' : undefined
                    });
                };
            }
            for (var i = 0; i < methods.length; i++) {
                createMethod(methods[i]);
            }
        })();

softexe avatar Mar 16 '16 04:03 softexe

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jun 25 '18 18:06 lock[bot]