﻿/* JScript File*/

  /*This method returns an instance of xmlHttpObject
  handler is the callback method which needs to be called when a request is completed.*/
function GetXmlHttpObject(handler)
{ 
    var objXmlHttp = null;
    if (!window.XMLHttpRequest)
    {
        /*Microsoft*/
        objXmlHttp =new ActiveXObject("Microsoft.XMLHTTP");
        if (objXmlHttp != null)
        {
            objXmlHttp.onreadystatechange = handler;
        }
    } 
    else
    {
        /*Mozilla | Netscape | Safari*/
        objXmlHttp = new XMLHttpRequest();
        if (objXmlHttp != null)
        {
            objXmlHttp.onreadystatechange = handler;
        }
    } 
    return objXmlHttp; 
} 

/*This method sends a Get Request to the specified url.
  xmlHttp is the object of xmlHttp.
  url is the url of the page which should be contacted to retrieve data.*/
function SendXmlHttpGetRequest(xmlHttp, url) 
{ 
    xmlHttp.open('GET', url, true); 
    xmlHttp.send(null); 
}

/*This method sends a POST Request to the specified url.
  xmlHttp is the object of xmlHttp.
  url is the url of the page which should be contacted to retrieve data.*/
function SendXmlHttpPostRequest(xmlHttp, url, sData) 
{     
    xmlHttp.open("Post",url,true);
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xmlHttp.send(sData);
}
