mui.ajax获取后台数据的写法

mui.ajax获取后台数据 。

var ErpApi = {
    api_url: "地址",
    ajax: function(url, data, Callback) {
        mui.ajax(url, {
            async: true,
            data: data,
            dataType: 'json',
            type: 'post',
            timeout: 10000,
            headers: {
                'Content-Type': 'application/json'
            },
            // 服务器返回来的data
            success: function(data) {

                if(!data.d.IsAuth) {
                    mui.alert("凭证已失效,请重新登录!", function() {
                        window.location.href = "login.html?url=" + window.location.href;
                    });
                } else {
                    Callback(data);
                }
            },
            error: function(xhr, type, errorThrown) {
                console.log(type + "," + errorThrown);
                //                mui.alert("数据错误!", "提示", "确定", function() {
                //                    window.location.href = "person.html";
                //                });
            }
        });
    },

猜你喜欢

转载自blog.csdn.net/qq_38332693/article/details/88691935