2012-10-25 2 views
1
_setPrintExportCookieInterval: function(/**String*/requestId, /**function*/closePopup) { 
    //have the interval autoexpire after some amount of seconds 
    var count = 0; 
    var intervalMs = 2000; 

    var intervalId = self.setInterval(function() { 
     var reportCookie = dojo.cookie(requestId); 
     console.debug('requestId ' + requestId); 
     if(reportCookie || count > 300000) { //5 mins 
      //if there's a status failure, don't close the window 
      console.debug('reportCookie ' + reportCookie); 
      if(reportCookie == undefined){ 
       console.debug("print/export request returned with undefined status "); 
      } else if(reportCookie == "success") { 
       closePopup(); 
      } else{ 
       console.debug("print/export request returned with nonstandard status " + reportCookie); 
      } 
      window.clearInterval(intervalId); 
      //delete the cookie 
      dojo.cookie(requestId, null, {path: "/", expires: -1}); 
      //destroy the iframe 
      //dojo.destroy(dojo.byId(requestId)); 
     }; 
     count+=intervalMs; 
    }, intervalMs); 

    return intervalId; 
}, 

위의 javascript 기능에 문제가 있습니다.dojo.cookie (id)가 간헐적으로 id로 쿠키를 찾을 수 없습니다.

var reportCookie = dojo.cookie(requestId); 

반환 null,하지만 난 내 브라우저의 디버깅 도구에서 볼 때 나는 쿠키 success의 값이 존재하는 것을 볼 수 있어요 :이 문제는 일반적으로 때로는이다. 이것은이 함수가 호출 될 때마다 10 번 발생합니다. 어떤 아이디어가 dojo.cookie() 일 때만 ID로 쿠키를 검색 할 수없는 이유는 무엇입니까?

답변

1

쿠키를 검색 할 때 경로를 지정했는지 확인하십시오. 그렇지 않으면 현재 위치가 기본값입니다. 이렇게하면 도메인 내의 모든 경로에서 쿠키를 가져올 수 있습니다. 내가 경로 쿠키 설정시에 "/"(못하고)를 설정해야했을 때

dojo.cookie(requestId, null, {path: "/" });

+0

나를 위해 일했다. – kaze

관련 문제