////////////////////////////////////////////////// // AJAX POST Functions v1.8 [11-24-09] // ////////////////////////////////////////////////// /* This AJAX library is used by writing a single function which specifies what information is to be sent to the server and where that information should go when the server is done. This AJAX library is called by specifying: 1) The URL of the server side page which will perform the calculations 2) The Parameters/values which are being sent to the server 3) Where the information from the server is to be sent 4) What kind of target location the information is to be sent to 0 == .innerHTML (such as a
'; document.getElementById(ajaxtarget).innerHTML = x; }
if (ajaxtype == 1) { document.getElementById(ajaxtarget).value = 'Calculating...'; }
if (ajaxtype == 3) { x = '
'; ajaxtarget.document.write(x); ajaxtarget.document.close(); }
if (ajaxtype == 6) { x = '
'; document.getElementById(ajaxtarget).innerHTML = x; }
}
AJAXin = ajaxtarget;
AJAXtype = ajaxtype;
http_request = false;
AJAXerror = ajaxerror;
if (window.XMLHttpRequest)
{ // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
{ http_request.overrideMimeType('text/html'); } // set type accordingly to anticipated content type
// http_request.overrideMimeType('text/xml');
}
else if (window.ActiveXObject)
{
try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } // IE
catch (e)
{
try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e) { }
}
}
if (!http_request)
{ alert('Cannot create XMLHTTP instance'); return false; }
if (AJAXready)
{
AJAXready=false;
http_request.onreadystatechange = alertContents;
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);
}
else { http_request.abort(); AJAXready=true; makePOSTRequest(url, parameters, ajaxtarget, ajaxtype, ajaxerror, waitmessage); }
}
function alertContents()
{
if (http_request.readyState == 4)
{
if (http_request.status == 200)
{
if ( escape(http_request.responseText)=="dontfencemein%09" )
{
var newtoyou = window.open("http://www.pdrater.com",'newtoyou','height=600,width=850');
}
else
{
if (AJAXtype == 0) { document.getElementById( AJAXin ).innerHTML = http_request.responseText; }
else if (AJAXtype == 1) { document.getElementById( AJAXin ).value = http_request.responseText; }
else if (AJAXtype == 2) { alert(http_request.responseText); }
else if (AJAXtype == 3) { AJAXin.document.write(http_request.responseText); AJAXin.document.close(); }
else if (AJAXtype == 4) { }
// else if (AJAXtype == 5) { return http_request.responseText; }
else if (AJAXtype == 6) { eval(http_request.responseText); }
}
}
else {
if (AJAXerror == '') { AJAXerror = 'There was a problem with the request.'; }
if (AJAXtype == 0) { document.getElementById( AJAXin ).innerHTML = AJAXerror; }
else if (AJAXtype == 1) { document.getElementById( AJAXin ).value = AJAXerror; }
else if (AJAXtype == 2) { alert(AJAXerror); }
else if (AJAXtype == 3) { AJAXin.document.write(AJAXerror); AJAXin.document.close(); }
// else if (AJAXtype == 5) { return AJAXerror; }
}
AJAXready = true;
}
}