[thelist] Prototype/AJAX Neubie question

Phillip M. Vector phillipmvector at comcast.net
Sun Jul 15 21:20:59 CDT 2007


Can someone tell me how I can have 2 separate ajax threads?

Whenever I run the code below, it works as long as only 1 is triggered 
at a time.

How do I make essentially 2 separate AJAX calls and keep the data coming 
back separate?



=====================================================================
<script>
		function showmessages()
		{
			xmlHttp=GetXmlHttpObject()
			var url="CheckMessages.cfm";
					url=url+"&room="+document.getElementById("Room").value;
			xmlHttp.onreadystatechange=stateChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}

		function stateChanged()
		{
			if (xmlHttp.readyState==4)
			{
				document.getElementById("Messages").innerHTML=xmlHttp.responseText;
			}
		}
</script>


<script>
		function checkusers()
		{
			xmlHttp=GetXmlHttpObject()
			var url="CheckUsers.cfm";
			xmlHttp.onreadystatechange=UsersChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}

	function UsersChanged()
	{
		if (xmlHttp.readyState==4)
		{
			document.getElementById("Users").innerHTML=xmlHttp.responseText;
		}
	}
</script>




More information about the thelist mailing list