2013-09-04 3 views
0

내 응용 프로그램에서 중복 된 그룹 이름을 피하기 위해 사용자가 AJAX 호출을 통해 입력 한 값의 유효성을 검사하려고했습니다. 그러나 예상 된 응답 텍스트를받지 못하고 있지만 캐시에서 responseText를받는 중입니다. JS 파일 : { if (window.ActiveXObject) // IE var xhr = new ActiveXObject ("Microsoft.XMLHTTP"); else if (window.XMLHttpRequest) // 기타 var xhr = new XMLHttpRequest(); else 경고 ("귀하의 브라우저는 AJAX를 지원하지 않습니다"); } 캐치 (전자) {경고 ("xmlhttpresponse creting의 오류 :"+ 전자);}xmlHttpResponse 객체가 IE7에서 적절한 responseText를 반환하지 않음

escName= document.forms(0).txtEscalationName.value; 
    escId = document.forms(0).hidGroupId.value; 

    urlParam = "escName=" +escName +"&escCode=" +escId; 
    alert(".."+urlParam);  
    xhr.open("GET", "/myapp/jsp/main/escalationNameCheck.jsp?"+urlParam+"&ran="+Math.random() ,true); 

xhr.setRequestHeader("Cache-Control","no-cache"); 
xhr.setRequestHeader("Pragma","no-cache"); 
xhr.onreadystatechange = function() { 

    if (xhr.readyState == 4) 
    {    
     if (xhr.status == 200) 
     { 
      if (xhr.responseText != null) 
      { 

      alert(document.getElementById("escalationNameValidate")); 

       try{ 
       var populate = document.getElementById("escalationNameValidate"); 

       populate.innerHTML = xhr.responseText; 
       }catch(e){ 

       alert("ERROR!...."+e); 
      } 
      } 
      else 
      { 
       alert("Failed to receive JSP file from the server - file not found."); 
       return false; 
      } 

     } 
     else 
      alert("Error code " + xhr.status + " received: " + xhr.statusText); 
    } else 
    alert("not ready"); 
} 
xhr.send(null); 

여기 참조 후 : responseText - XMLHttpRequest 나는 아래와 같은 이벤트를 언급 시도했지만 그것은 대상 또는 null의 말을 예외를 준 물건이 아닙니다. xhr.onreadystatechange = function (이벤트) { var xhr = event.target; (xhr.readyState == 4) {alert ("first if");
if (xhr.status == 200) {alert ("second if"); (xhr.responseText! = null)

  alert(document.getElementById("escalationNameValidate")); 

       try{ 
       var populate = document.getElementById("escalationNameValidate"); 
       alert("11"); 
       alert("pop.."+populate.innerHTML); 
       populate.innerHTML = xhr.responseText; 
       }catch(e){ 

       alert("ERROR!.xhr..."+e); 
      } 
      } 
      else 
      { 
       alert("Failed to receive JSP file from the server - file not found."); 
       return false; 
      } 
      alert("escNameDuplicate"+document.getElementById("escNameDuplicate")); 
     } 
     else 
      alert("Error code " + xhr.status + " received: " + xhr.statusText); 
    } else 
    alert("not ready"); 
} 

그래서 나는 그것을 정의하는 동안 var에 XHR을 사용하여에 RequestHeader에서 노 캐시로 지역 변수로 2. 만들기 XHR을 캐시 제어를 제공 1.했습니다. 3. onreadystatechange 함수에서 이벤트 인스턴스를 가리 킵니다. 브라우저 버전 : IE7

친절히 도와주세요. 감사합니다. Nidhya

답변

0

IE 설정에서 몇 가지 옵션을 수정하여이 작업을 수행했습니다. 브라우저를 닫고 IE를 다시 열어도 내 응답이 브라우저에 캐시되고있었습니다. 그럼 내가 한 일은 도구 -> 인터넷 옵션으로 이동했습니다. 브라우저 기록에서 설정 선택 "저장된 페이지의 최신 버전 확인 :" 설정을 저장하면 "웹 페이지를 방문 할 때마다"를 선택하십시오.

희망은 다른 사람에게 도움이되기를 바랍니다.

관련 문제