• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    设置默认Ajax操作cache and error

    复制代码 代码如下:

        // 设置Ajax操作的默认设置
        $.ajaxSetup({
            cache: false, 
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                if( typeof(errorThrown) != "undefined" )
                    $.messager.alert(g_MsgBoxTitle, "调用服务器失败。br />" + errorThrown ,'error');
                else{
                    var error = "b style='color: #f00'>" + XMLHttpRequest.status + "  " + XMLHttpRequest.statusText + "/b>";
                    var start = XMLHttpRequest.responseText.indexOf("title>");
                    var end = XMLHttpRequest.responseText.indexOf("/title>");
                    if( start > 0 end > start )
                        error += "br />br />" + XMLHttpRequest.responseText.substring(start + 7, end);
                        $.messager.alert(g_MsgBoxTitle, "调用服务器失败。br />" + error ,'error');
                }
            }
        });


    这样在ajax方法中你就可以不要写error处理函数了

    您可能感兴趣的文章:
    • jQuery ajax cache缓存问题
    • IE图片缓存document.execCommand("BackgroundImageCache",false,true)
    • IE cache缓存 所带来的问题收藏
    • ajax的 IE cache 相关问题解决
    上一篇:在.ashx文件中获取cookies值实现代码
    下一篇:Asp.net的应用程序对象和页面生存周期
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    设置默认Ajax操作cache and error 设置,默认,Ajax,操作,cache,