All pastes #448350 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-04-19 16:21 UTC
rendered paste body
function ajaxObject()
{
	this.scriptName      = null;
	this.postString      = null;
	this.handlerFunction = null;
	this.handlerParams   = null;
	this.connection      = null;

	if(gScriptName != undefined)
	{
		this.scriptName    = gScriptName;
	}
	this.contentType = 'application/x-www-form-urlencoded';
	this.connection = this.createConnection();
}

ajaxObject.prototype = {
	createConnection: function () 
	{
		var requestObject;
		var browser = navigator.appName;
		if(browser == "Microsoft Internet Explorer")
		{
			requestObject = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else
		{
			requestObject = new XMLHttpRequest();
		}
		return requestObject; 
	}

	sendRequest: function()
	{
		this.connection.open('POST', this.scriptName, true);
		this.connection.setRequestHeader('Content-Type', this.contentType);
		this.connection.onreadystatechange = function() { this.handlerFunction(); };
		this.connection.send(this.postString);
	}
}

new ajaxObject();