Hi:
I am facing a problem in ajax.
My code functionality is retrieving data from database. For it i am using ajax.
i am including the code below which contains ajax function:
<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);
}
}
}
</script>
I am getting response from action class so there is no problem in my other code.
when fetchCorpClassTaxonomy(url) function is called it is going to IE block since i am using IE 7.0
After that
alert("readystate: "+ req.readyState);
is also coming.
but the function processStateChange() is not called.
The alert just inside the function :
alert("entered into processStateChange()"); is also not executing.
The problem is function processStateChange() is not called.
Please give me your valuable suggestions As Soon As Possible for solving the problem. Since i am new to Ajax I am not able to find the solution.
Thanks.....