2011-07-28 3 views
1

다음과 같은 현상에 대해 누구도 알 수 있습니까?브라우저 JQUERY 데이터 캐시 IE7

나는 그때 입력 한 데이터가 표시되지 않는 그래프 HighChart를 포함하는 ASPX 페이지로 이동 데이터베이스에 레코드를 입력하면 ASP.NET MVC 응용 프로그램이 대상 플랫폼 IE7

에서 실행해야합니다. 차트를 표시하려면 데이터를 얻으려면 브라우저를 닫고 응용 프로그램을 다시로드해야합니다.

디버그 모드에서 응용 프로그램을 실행하고 코드가 컨트롤러의 중단 점에 도달하지 않습니다. 마치 클라이언트 JQUERY 코드가 변경 사항이 없다고 생각하고 캐싱하는 것처럼 말입니다. 컨트롤러는 작동하지 않지만 이전 데이터로 작업하는 것처럼 실행됩니다.

내가 응용 프로그램을 다시로드 할 때 (중지 및 시작) 컨트롤러 화재 내가 디버깅 할 수와 최신 데이터가

미친 물건에 오는 것을 보장하기 위해 어딘가에서 web.config 아마도 설정을 할 수 또는합니다 클라이언트 JSON은 항상 컨트롤러와 캐시하지 고토 호출

아래 필요한 경우 많은

J

CODE

감사 모든 의견 :

function CreateChart1(surl) { 

     // Code block for fetching Array as jsonResult (js) 
     var url = $("#AbsolutePath").val() + "Incident.mvc/GetChartData_IncidentsBySiteStatus/" + surl; 

     var chart; 
     $.getJSON(url, null, function(data) { 

      var result = []; 
      jQuery.each(data, function(i, val) { 
       result[i] = [val.Site, parseInt(val.Count)]; 
      }); 

      chart = new Highcharts.Chart({ 
       chart: { 
        renderTo: 'chart1', 
        plotBackgroundColor: null, 
        plotBorderWidth: null, 
        plotShadow: false 
       }, 
       title: { 
        text: 'Number of Environmental Incidents by Site Status' 
       }, 
       tooltip: { 
        formatter: function() { 
        return '<b>' + this.point.name + '</b>: ' + this.y + ' (' + Math.round(this.percentage) + '%)'; 
        } 
       }, 
       plotOptions: { 
        pie: { 
         allowPointSelect: true, 
         cursor: 'pointer', 
         dataLabels: { 
          enabled: true 
         }, 
         showInLegend: false 
        } 
       }, 
       exporting: { 
        enabled: true 
       }, 
       series: [{ 
        type: 'pie', 
        name: 'Incidents by Site Status', 
        data: result 

}] 
       }); 
      }); 
     }; 

컨트롤러 코드 :

public JsonResult GetChartData_IncidentsBySiteStatus(string SiteTypeId, string searchTextSite, string StartDate, string EndDate) 
    { 
     if (searchTextSite == null) 
      searchTextSite = ""; 

     DateTime startDate = DateTime.Parse(StartDate); 
     DateTime endDate = DateTime.Parse(EndDate); 

     IQueryable<Site> sitesQry = _db.Sites; 

     if (SiteTypeId != "-1") 
      sitesQry = sitesQry.Where(a => a.SiteTypeId.ToString() == SiteTypeId); 

     var qry = from i in _db.Incidents 
        join s in sitesQry on i.SiteId equals s.SiteId 
        where s.SiteDescription.Contains(searchTextSite) 
        && (i.Raised >= startDate && i.Raised <= endDate) 
        group s by s.SiteStatus.SiteStatusDescription + "[" + s.SiteTypeId.ToString().Replace("1","ON").Replace("0","OFF") + "]" 
         into grp 
         select new 
         { 
          Site = grp.Key, 
          Count = grp.Count() 
         }; 

     return Json(qry.ToList() , JsonRequestBehavior.AllowGet); 
    } 
+0

http://stackoverflow.com/questions/264216/getjson-returning-cached-data-in-ie8 : 당신이 캐싱을 비활성화해야합니다 지정할 수 있도록 전화를 확인하기 위해 ajax 방법을 사용할 수 있습니다 이게 도움이 될거야. – Rafay

답변

2

문제는 IE7이 AJAX를 통해 수행 된 GET의 rewuest도 캐시 것입니다. 일반적으로 쿼리 문자열에 임의의 숫자를 추가하여 요청이 캐시되지 않도록합니다.

당신은 할 수 :

var noCache = new Date().getTime(); 
//then add nocache as a paremter to the url 
var url = $("#AbsolutePath").val() + "Incident.mvc/GetChartData_IncidentsBySiteStatus/" + surl+"&nocache="+noCache; 
0

기본 설정을 AJAX가 jQuery를에 (스크립트와 JSONP 제외)를 호출 캐싱을 허용하기 때문이다.

$.ajax({ 
    cache: false, 
    url: url, 
    dataType: 'json', 
    success: function(data) { 
    ... 
    } 
});