All pastes #472474 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-05-05 16:36 UTC
rendered paste body
function ajaxReq(strURL, strSubmit, strResultFunc) {
	var xmlHttpReq = false;
	// Mozilla/Safari/IE7
	if (window.XMLHttpRequest) {
		xmlHttpReq = new XMLHttpRequest();
		if (xmlHttpReq.overrideMimeType)
			xmlHttpReq.overrideMimeType('text/xml'); // this would break IE7..
	}
	// <=IE6
	else if (window.ActiveXObject) {
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
        }
	xmlHttpReq.open('POST', strURL, true);
	xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlHttpReq.onreadystatechange = function() {
		if (xmlHttpReq.readyState == 4) {
			if (xmlHttpReq.status == 200) {
				if (strResultFunc) { // Run result function
					if (typeof strResultFunc == "string")
						eval(strResultFunc+'(xmlHttpReq);');
					else
						eval(strResultFunc(xmlHttpReq));
				}
				else // if no result function was specified, simply return true.
					return true;
				}
			}
                 }
       	         xmlHttpReq.send(strSubmit);
	}