Hi:
I am also have a problem with onreadystatechange .
here is the code below i am using:
<script>
var req;
var which;
function fetchCorpClassTaxonomy(url) {
alert("entered into Ajax function");
if (window.XMLHttpRequest) { // Non-IE browsers
alert("NON IE Block is Invoked");
req = new XMLHttpRequest();
req.onreadystatechange = processStateChange;
try {
req.open("GET", url, true);
} catch (e) {
alert(e);
}
req.send(null);
} else if (window.ActiveXObject) { // IE
alert("entered into IE block");
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
alert("entered into if(req)");
req.onreadystatechange = processStateChange;
req.open("GET", url, true);
alert("readystate: "+ req.readyState);
req.send();
}
}
}
function processStateChange() {
alert("entered into processStateChange()");
if (req.readyState == 4) { // Complete
if (req.status == 200) { // OK response
alert("response received from server is "+req.responseText);
var serverResponse = req.responseText;
var fieldName = serverResponse.substring(0,serverResponse.indexOf ("|"));
//alert("fieldname string "+fieldName);
var restResponse = serverResponse.substring(serverResponse.indexOf ("|")+1,serverResponse.length);
//alert("rest of Response is "+restResponse);
if(fieldName == "classification"){
document.getElementById("subclassification").innerHTML = restResponse;
}
} else {
alert("Problem: " + req.statusText);
}
}
}
The function processStateChange() is not called.
what might be the problem..
Please give me your valuable suggestion as soon as possible.
Thanks.....
++++++++++++++++++++++++++++++++++++++++++++++++
function reportStatus()
{
if (oReq.readyState == 4)
alert('Transfer complete.');
}
var oReq = new XMLHttpRequest();
oReq.onreadystatechange = reportStatus;
oReq.open("GET", "http://localhost/test.xml", true);
oReq.send();
I think you are using the "old" version of req = new ActiveXObject("Microsoft.XMLHTTP");
It will work if you specify var req = new XMLHttpRequest();