ajax禁止浏览器缓存

   把cache 设置为false ,把 ifModified 设置为true

//工作计划
function workprogram(date_time){
    $.ajax({
        async:false,
        url : 'selectMessageByDate',
        data :
        {  
            date_time : date_time
        },
        dataType : 'json',
         cache:false,        //这里
         ifModified :true , //这里
        success : function(data){
            var morning="";
            var noon="";
            var night="";
             var n1 = "";
             var n2 = "";
             var n3 = "";
             var n4 = "";
            var wordList = data[0];
            var forcastList = data[1];
            for(var i in wordList){
                var time = wordList[i].date_time;
                var type = wordList[i].type;
                var mess = wordList[i].message;
                if(type=="0"){
                    morning=mess+" ${morning} "+time;
                }else if(type=="1"){
                    noon=mess+" ${noon} "+time;
                }else if(type=="2"){
                    night=mess+" ${night} "+time;
                }
            }
            
            for(var i in forcastList){
                var str = forcastList[i].observTimes;
                var sitiId = forcastList[i].siteId;
                var bulbTemp = forcastList[i].bulbTemp;
                var precipitationAmount = forcastList[i].precipitationAmount;
                var windV = forcastList[i].windV;
                  str=str.substring(8);
                 str=str.substring(0,2);
                
                if(str=="00"){
                    if(sitiId=="54338"){//盘山
                        n1 = bulbTemp+" "+"${mpt}"+" "+precipitationAmount+" "+"${mpr}"+" "+windV+" "+"${mpw}";
                    }else if(sitiId=="54470"){//大洼
                        n2 = bulbTemp+" "+"${mdt}"+" "+precipitationAmount+" "+"${mdr}"+" "+windV+" "+"${mdw}";
                    }
                
                } else if(str=="12"){
                        if(sitiId=="54338"){
                            n3 = bulbTemp+" "+"${npt}"+" "+precipitationAmount+" "+"${npr}"+" "+windV+" "+"${npw}";
                        }
                        else if(sitiId=="54470"){
                            n4 = bulbTemp+" "+"${ndt}"+" "+precipitationAmount+" "+"${ndr}"+" "+windV+" "+"${ndw}";
                        }
                    }
            }
            
            replaceWord(morning+","+noon+","+night+";"+n1+","+n2+","+n3+","+n4+";"+date_time);
        }
        
    });

}

posted on 2016-10-26 15:12  guols  阅读(5090)  评论(0编辑  收藏  举报