首页 > Web开发 > 详细

Ajax缓存

时间:2015-05-10 23:59:59      阅读:465      评论:0      收藏:0      [点我收藏+]
//  Ajax缓存 请求一次,页面不会在次访问这个方法,会读取缓存数据
$(".routeTips").live("mouseenter",function () {
    var $this = $(this);
    var billcode = $(this).attr("data-sitecode");
    var key = "A027" + billcode;
    if (isCache) {
        if (cacheRouteTips[key]) {
            $this.manhua_bubbletips({ position: "t", value: 35, content: cacheRouteTips[key] + "", last: true });
        } else {
            if (req) {
                req.abort();
            }
            postData();
        }
    }else {
        postData();
    }
    function postData() {
        req = $.ajax({
            type: "post",
            dataType: "json",
            url: "/postdate.aspx",
            data: "id=" + billcode + "&type=A018",
            cache: false,
            timeout: 20000,
            success: function (msg) {
                if (msg.Result[0]["status"] == "true") {
                    $this.manhua_bubbletips({ position: "t", value: 35, content: msg.Result[0]["site"] + msg.Result[0]["tel"] + "", last: true });
                    cacheRouteTips[key] = msg.Result[0]["site"] + msg.Result[0]["tel"];
                }
            }
        });
    }
});

 

Ajax缓存

原文:http://www.cnblogs.com/linbicheng/p/4493392.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!