/**
 * 发送请求
 * @param urlname
 * @param data
 * @param success
 * @param error
 * @param before
 */
function sendajax(urlname,data,success,error,before) {
    if (typeof(before) == 'undefined'){
        before = function(XMLHttpRequest){}
    }
    if (typeof(error) == 'undefined'){
        error = function(XMLHttpRequest, textStatus, errorThrown){
            //console.log(XMLHttpRequest);
            //console.log(textStatus);
            //console.log(errorThrown);
            let msg = '网络错误,请刷新网页重试!';
            //console.log(typeof XMLHttpRequest.responseJSON);
            if(typeof XMLHttpRequest.responseJSON !== "undefined"){
                if (typeof XMLHttpRequest.responseJSON.message !== "undefined"){
                    msg = XMLHttpRequest.responseJSON.message;
                }
            }else{
                if(typeof XMLHttpRequest.responseText !== "undefined"){
                    msg = XMLHttpRequest.responseText;
                }
            }

            try{
                layer.alert(msg, {
                    skin: 'layui-layer-lan',
                    closeBtn: 0,
                    title:'StatusCode : '+XMLHttpRequest.status
                });
            }catch (e) {
                alert('StatusCode : '+XMLHttpRequest.status+'|'+msg);
            }
        }
    }

    $.ajax({
        url: urlname,
        dataType: "json",
        cache: false,
        data: data,
        type: "POST",
        timeout:60000,
        async:false,
        beforeSend:before,
        success:success,
        error:error
    });
}