I'm using JavaScript to send textarea updates back to a server in real-time. My HTML page uses a single XMLHttpRequest object to POST data to the server asynchronously. The messages are sent potentially at every onKeyUp event, but because I only use a single XMLHttpRequest object I throttle the requests by only POSTing when the readyState is either 0 (uninitialized) or 4 (loaded).
Against IIS6 on Windows 2003 Server, everything is working fine. Against IIS7 on Windows 7 Professional, the readyState of my XMLHttpRequest object gets stuck at 1 (initialized) if I type in several characters quickly.
The number of characters I can get in varies from 3 to 20 or so. If I reload the page, I can enter in a few more characters until I get stuck again. If I type slowly, then I can enter more characters before I see the problem. [Could this have anything to do with connection limits on IIS7?]
Also, if I use GET instead of POST, everything works fine (except that GET won't support the length of data I need to send).
Here's a snippet of the important bits of code here. Anyone have any insight into this problem? Thanks in advance.
var _xml = getXmlHttpRequest();
function getXmlHttpRequest()
{
if (window.XMLHttpRequest)
return new XMLHttpRequest();
else if (window.ActiveXObject)
return new ActiveXObject("Microsoft.XMLHTTP");
alert ("Upgrade your browser, Fool!");
return null;
}
function postValue(value)
{ // sends the answer to the server for saving
if (_xml.readyState == 4 || _xml.readyState == "0")
{
var params = "value=" + encodeURIComponent(value);
_xml.open("post", "save.py", true);
_xml.onreadystatechange = handlePostValue;
_xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
_xml.setRequestHeader("Content-Length", params.length);
_xml.setRequestHeader("Connection", "close");
_xml.send(params);
}
}