码迷,mamicode.com
首页 > Web开发 > 详细

Ajax缓存

时间:2015-05-11 00:01:42      阅读:341      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!