I have been successfully implementing Ajax in my application across various browsers, however, I am encountering issues with Internet Explorer. Below is the code that I have developed - could you please review it and provide guidance on where I might be making a mistake? Here's the code:
<script type="text/javascript>
function loadXMLDoc(str) {
document.getElementById('spinner').style.display = "block";
if (str == "") {
document.getElementById("pickZone").innerHTML = "";
document.getElementById('spinner').style.display = "none";
return;
}
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
xmlhttp = false;
}
}
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById('spinner').style.display = "none";
document.getElementById("pickZone").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "getPickZone.jsp?q=" + str, true);
xmlhttp.send();
}
</script>