Ajax缓存

//  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"];
                }
            }
        });
    }
});

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。