Hello,
I have a small test application (see the code below) which works fine in Firefox, but not really in IE. As you can see on every value change event I want to display an alert. In case of IE the first 2 changes works fine but after no more alert. If I restart the browser then again 2 times I get the alert message but after nothing.
Any idea what is wrong?
Code:
<script language="javascript" type="text/javascript">
<!--
// Get the HTTP Object
function getHTTPObject(){
if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) return new XMLHttpRequest();
else {
alert("Your browser does not support AJAX.");
return null;
}
}
// Change the value of the outputText field
function setOutput(){
if(httpObject.readyState == 4){
alert("OK");
}
}
// Implement business logic
function doWork(){
httpObject = getHTTPObject();
if (httpObject != null) {
httpObject.open("GET", "category.php?brand="
+document.getElementById('brand').value, true);
httpObject.send(null);
httpObject.onreadystatechange = setOutput;
}
}
var httpObject = null;
//-->
</script>
<form name="testForm" action="">
<select name="brand" id="brand" onchange="doWork();">
<option value="Test-1">Test-1</option>
<option value="Test-2">Test-2</option>
</select>
</form>