/**
 * @param {Object} url
 * @param {Object} param
 * @param {Object} callback
 */
function requestService(url, param, callback, async, errCallback) {
    /*
     * 스프링시큐리티 csrf 토큰 에러때문에  ajax 통신시 해더에 포함해줘야한다.
     */

    if (async) {

        async = true;
    }

    $.ajax({
        url: _WEB_CONTEXT_NAME + "/" + url
        , data: param
        , cache: false
        , async: async
        , type: 'POST'
        , success: callback
        , error: (err)=>{
            if (errCallback) {
                errCallback(err);
            }
            else {
                whenError();
            }
        }
    });
}

/**
 *
 * @param url
 * @param formName
 * @param callback
 * @param async
 */
function requestServiceForm(url, formName, callback, async) {

    if (async) {

        async = true;
    }

    $("#" + formName).ajaxSubmit({

        url: _WEB_CONTEXT_NAME + "/" + url
        , data: $(this).serialize()
        , cache: false
        , async: async
        , type: 'POST'
        , success: callback
        , error: whenError

    });
}

function whenError() {

    console.log('ajax error');

}