zhangcheng001
        var ajaxTimeout = $.ajax({
            type: "POST",
            dataType: "json",
            url: "{:url(\'admin/comment/status\')}",
            timeout: 2000,
            data: {
                \'status\': status,
                \'id\': id
            },
            success: function (res) {
                $(\'#loading\').addClass(\'hidden\');
                if (res.code == 1) {
                    layer.msg(res.msg, {
                        icon: 6,
                        time: 2000
                    }, function () {
                        window.location.href = res.url;
                    })
                } else {
                    layer.open({
                        title: \'操作失败\',
                        content: res.msg,
                        icon: 5,
                        anim: 6
                    })
                }
            }, complete: function (XMLHttpRequest, status) { 
                $(\'#loading\').addClass(\'hidden\');
                if (status == \'timeout\') {  //超时,status还有为timeout
                    ajaxTimeout.abort();
                    layer.confirm(\'请求超时\', {
                        title: "请求超时",
                        icon: 5
                    }, function (index) {
                        layer.close(index);
                    })
                }
            }
        });

 

分类:

技术点:

相关文章: