В моем приложении inorder, чтобы избежать дублирования имен групп Im пытается проверить введенное пользователем значение через вызов AJAX. Но я не получаю ожидаемый ответText, но im получаю responseText из кеша. JS-файл: try { if (window.ActiveXObject) // IE var xhr = new ActiveXObject ("Microsoft.XMLHTTP"); else if (window.XMLHttpRequest) // другой var xhr = new XMLHttpRequest(); еще предупреждение («ваш браузер не поддерживает AJAX»); } поймать (е) {Alert («Ошибка привыкли это xmlhttpresponse:» + е);}xmlHttpResponse объект не возвращает правильный responseText в IE7
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 я попытался упомянуть событие, как показано ниже, но это дало исключение говоря цель нуль или а не объект. xhr.onreadystatechange = function (event) { var xhr = event.target; if (xhr.readyState == 4) {alert ("first if");
if (xhr.status == 200) {alert ("second if");
if (xhr.responseText! = Null) {alert ("third if" + xhr.responseText);
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");
}
Так что я попытался 1. давая кэш-контроль, как не-кэша в RequestHeader 2. Making XHR в качестве локальной переменной с помощью уаг XHR при определении его. 3. также указал событие-событие в функции onreadystatechange. Версия браузера: IE7
Просьба оказать помощь. С уважением, Nidhya