Saturday, February 10, 2018

ajax global default setting

(function($) {
    $(document).ready(function(){
        // ajax global default setting
        $.ajaxSetup({
            contentType: 'Content-Type: application/json',
            method: 'POST',
            dateType: 'json',
        });

        //
        let obj = {Asdf: 'asdf'};

        $.ajax({
            url: '/admin/region/request',
            data: JSON.stringify(obj),
        }).done(function(data) {
            console.log(data);
        }).fail(function(jqXHR, textStatus) {
            console.log(jqXHR.responseJSON);
        }).always(function(data) {
        });
    });
})(jQuery);

No comments: