I have programmed a game in AJAX that checks the server every 2 seconds with XMLHttpRequest for new data. The updating part works fine, but sometimes, when a user presses an options button to perform an action, everything in the function on the button click works, but the http request doesn't go through so the action is never executed. I am wondering if anyone knows why this is happening. Could it possibly be that the http request that happens every 2 seconds overlaps the one made from the button press and keeps the button's request from going through?

Code:
function ajax_request2(url) {
try {
  http_request2 = new XMLHttpRequest();
} catch (trymicrosoft) {
  try {
    http_request2 = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (othermicrosoft) {
    try {
      http_request2 = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (failed) {
      http_request2 = false;
    }
  }
}

if(!http_request2) {
alert('Error: Connection failed.');
return false;
}
http_request2.onreadystatechange=alertContents2;
http_request2.open('GET',url,true);
http_request2.send(null);
}

function alertContents2() {
	if(http_request2.readyState==4) {
		if(http_request2.status==200){
			rec_content(http_request2.responseText);
		} else { alert("HTTP Request Failed"); }
	} else { alert("HTTP Request Failed"); }
}