2013-11-04 37 views
0

我无法查看数据库中更新的新搜索结果。只使用Internet Explorer 8.我尝试刷新页面,但是什么都不做。 Chrome和Firefox可以正常工作。在jQuery中为Internet Explorer 8禁用缓存问题

我可以通过选择“检查存储页面的新版本:每次访问网页时暂时解决此问题”。但是,当我将其投入生产时,这意味着它不适用于使用IE 8 9或10的最终用户。

任何有用的提示,将不胜感激。提前致谢。

以下是我已经尝试:

<script> type=“text/javascript" src="js/jquery-1.9.1.min.js?new=yes"></script> 

$(document).ready(function() { 
    //http://stackoverflow.com/questions/217957/how-to-print-debug-messages-in-the-google-chrome-javascript-console/2757552#2757552 
    if (!window.console) console = {}; 
    console.log = console.log || function() {}; 
    console.dir = console.dir || function() {}; 

    //listen for keyup on the field 

    $("#searchField").keyup(function() { 
     //get and trim the value 
     var field = $(this).val(); 

     field = $.trim(field) 

     //if blank, nuke results and leave early 

     if (field == "") { 
      $("#results").html(""); 

      return; 
     } 

     console.log("searching for " + field); 

     $.getJSON("cfc/test.cfc?returnformat=json&method=search", { 
      "search": field 
     }, function (res, code) { 

      var s = "<table width='1000' class='gridtable' name='table1' border='1'><tr><th width='40'>Attuid</th><th width='80'>Device</th><th width='55'>Region</th><th width='140'>Problem</th><th width='160'>Description</th><th width='120'>Resolution</th> <th width='180'>Resolution Description</th><th width='40'>Agent</th><th width='140'>Timestamp</th></tr>"; 

      s += ""; 

      for (var i = 0; i < res.table_demo.length; i++) { 
       s += "<tr><td width='42'>" + res.table_demo[i].pa_uid + 
        "</td><td width='80'>" + res.table_demo[i].pa_device + 
        "</td><td width='55'>" + res.table_demo[i].pa_region + 
        "</td><td width='140'> " + res.table_demo[i].pa_problem + 
        "</td><td width='160'> " + res.table_demo[i].pa_description + 
        "</td><td width='120'>" + res.table_demo[i].pa_resolution + 
        "</td><td width='180'>" + res.table_demo[i].pa_rdescription + 
        "</td><td width='42'> " + res.table_demo[i].pa_agent + 
        "</td><td width='140'> TimeStamp" 
       "</td>"; 

       s += "</tr>"; 
      } 

      s += "</table>"; 

      $("#results").html(s); 
     }); 
    }); 
}) 
+0

禁用缓存:

而且过期的页面瞬间,试着加入meta标签。 –

+0

你看过HTTP缓存头吗? http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/ –

+0

它可能只是一个剪切和粘贴错误,但这看起来不正确:'' – duncan

回答

1

尝试$.ajaxSetup({ cache: false });所以禁用jQuery的缓存。 ,或通过使用$就代替(首选)通过ajaxSetup

<meta http-equiv="Pragma" content="no-cache"/> 
<meta http-equiv="Expires" content="-1" /> 
+0

Thank you,that worked – Seansa