Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-16-2007, 09:45 AM   PM User | #1
elmu
New Coder

 
Join Date: Mar 2005
Posts: 48
Thanks: 2
Thanked 0 Times in 0 Posts
elmu is an unknown quantity at this point
Problem with onreadystatechange in IE

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>
elmu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:38 PM.


Advertisement
Log in to turn off these ads.