﻿// JScript File containing basic AJAX utility methods

function initXMLHTTPRequest()
//returns an XMLHTTPRequest object instance.
{
    var xRequest = null;
    if (window.XMLHttpRequest)
    {
        xRequest = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        xRequest = new ActiveXObject('Microsoft.XMLHTTP');
    }
    return xRequest;
}

function sendAJAXRequest(url, params, httpMethod, asynchronous)
//sends an asynchronous request to the server. Url = the url to submit to.
//params = name/value pairs to send to the server. httpMethod = GET or POST.
//asynchronous = true or false.
{
    if (!httpMethod)
    {
        httpMethod = 'GET';
    }
    req = initXMLHTTPRequest();
    if (req)
    {
        //alert('request created');
        req.open(httpMethod, url, asynchronous)
        req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        req.send(params);
        return req.responseText;
    }
}