﻿// JScript File


// Function to make an HTTP request for some data to the web server.
function getData(iPostPage, iMessage)
{
	try
	{
		// Create the HTTP request object.
		var oHTTP = createHTTPObject();
		var respText = '';

        // Check that the HTTP request object has been created successfully.
		if (!oHTTP)
		{
			alert('Creation of XMLHTTP instance has failed.');
		}
		else
		{
			// Set the POST location.
			oHTTP.open("POST",iPostPage,false);

//if(rID==22)
//{
//	alert(iMessage);
//}

			// Action the send.
			//oHTTP.send(oTrans);
			oHTTP.send(iMessage);

            // Get the response from the web server and pass into a string.
			respText = oHTTP.responseText;			
		}

		// Tidy up.
		oHTTP = null;

//if(rID==22)
//{
//	alert(respText);
//}

		// Return data to calling function.
		return respText;
	}
	catch(e)
	{
		alert('getData:\n'+e.description);
	}
}

function createHTTPObject()
{
	var xmlhttp;

    if (window.XMLHttpRequest) 
    { // Mozilla, Safari, ...
        xmlhttp = new XMLHttpRequest();
        if (xmlhttp.overrideMimeType) 
        {
            xmlhttp.overrideMimeType('text/xml');
            // See note below about this line
        }
    } 
    else if (window.ActiveXObject) 
    { // IE
        try 
        {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) 
        {
            try 
            {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e) {}
        }
    }
    
    // return the object.
	return xmlhttp;
}
