ajax請求超時


        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);
                    })
                }
            }
        });

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM