使用html5本地存储优化网页请求

(function(s){
	if(s){
		var userCity = s.getItem("userCity");
		if( userCity == null ){
			$.get("/index/userCity",null,function(d){s.setItem("userCity",d);$("#AsyncUserCity").html(d)});
		}else{
			$("#AsyncUserCity").html(userCity);
		}
		var hotKeywords = s.getItem("hotKeywords");
		if( hotKeywords == null ){
			$.get("/index/hotKeywords",null,function(d){s.setItem("hotKeywords",d);$("#AsyncHotKeywords").html(d)});
		}else{
			$("#AsyncHotKeywords").html(hotKeywords);
		}
	}else{
		$("#AsyncUserCity").load("/index/userCity");
		$("#AsyncHotKeywords").load("/index/hotKeywords");
	}
})(window.sessionStorage);

发表评论

电子邮件地址不会被公开。 必填项已用*标注