zoukankan      html  css  js  c++  java
  • 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);
                        })
                    }
                }
            });
    ╰︶﹉⋛⋋⊱⋋๑๑⋌⊰⋌⋚﹉︶╯
  • 相关阅读:
    node
    ionic
    关于websocket和ajax无刷新
    HTML图片热区
    npm -D -S -g -i 以及安装技巧
    es6 webpack转es5
    es6
    es6
    ssh tunnel
    vim上次和下次光标位置
  • 原文地址:https://www.cnblogs.com/zhangcheng001/p/12536879.html
Copyright © 2011-2022 走看看