Okay so, I found the code below and adapted it so it could be used on multiple pages; login, registration, etc.

What I'm making is a game, and on a certain page areas of the page will need to be reloaded. As soon as I added a new parameter (div) into the functions the alertContents doesn't seem to work.

The functions work like this:
In the html form code the get function collects the information on the form, then, depending on the page parameter, the switch statement collects the forms code for the post information. The post information is then passed into the post function where the function determines the browser that is being used, then set the function to run when the http request state is changed. This is the point where I believe it to be broken. From there the alertContents function outputs the result of the processing from the server.

code:
Code:
var http_request = false;
function makePOSTRequest(url, parameters, div) 
{
	http_request = false;
	if (window.XMLHttpRequest) 
	{ // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			// set type accordingly to anticipated content type
			//http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('text/html');
		}
	}
	else if (window.ActiveXObject) 
	{ // IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) 
			{
			}
		}
	}
	if (!http_request) 
	{
		alert('Cannot create XMLHTTP instance');
		return false;
	}

	http_request.onreadystatechange = alertContents(div);			
	http_request.open('POST', url, true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
}
   
function alertContents(div) 
{
	if (http_request.readyState == 4) 
	{
		if (http_request.status == 200) 
		{
			//alert(http_request.responseText);
			result = http_request.responseText;
			document.getElementById(div).innerHTML = result;                     
		} 
		else 
		{
			alert('There was a problem with the request.');
		}
	}
}
   
function get(obj, page, div) 
{
	switch (page)
	{
		case 'login.php':
			var poststr = "un=" + escape(encodeURI( document.getElementById("un").value )) +
							"&pw=" + escape(encodeURI( document.getElementById("pw").value )) +
							"&login=" + escape(encodeURI( document.getElementById("login").value ));
			makePOSTRequest(page, poststr, div);
			refresh();
		break;
		case 'register.php':
			var poststr = "un=" + escape(encodeURI( document.getElementById("un").value )) +
							"&pw=" + escape(encodeURI( document.getElementById("pw").value )) +
							"&cpw=" + escape(encodeURI( document.getElementById("cpw").value )) +
							"&em=" + escape(encodeURI( document.getElementById("em").value )) +
							"&register=" + escape(encodeURI( document.getElementById("register").value ));
			makePOSTRequest(page, poststr, div);
		break;
		case 'chat_insert.php':
			var poststr = "msg=" + escape(encodeURI( document.getElementById("msg").value ));
			makePOSTRequest(page, poststr, div);
		break;
		case 'home.php':
			var poststr = "logout=" + escape(encodeURI( document.getElementById("logout").value ));
			makePOSTRequest(page, poststr, div);
			refresh();
		break;
	}
}