
var xmlHttp;

//Creating and setting the instance of appropriate XMLHTTP Request object to a "XmlHttp" variable
function CreateXMLHTTP()
{
    try
    {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(oc)
        {
            xmlHttp = null;
        }
    }

    //Creating object in Mozilla and Safari
    if(!xmlHttp && typeof XMLHttpRequest != "undefined")
    {
        xmlHttp = new XMLHttpRequest();
    }
}

function sendRequest(url,mthod,callback,param)
{
    CreateXMLHTTP();

    // If browser supports XMLHTTPRequest object
    if(xmlHttp)
    {
        //Setting the event handler for the response
        xmlHttp.onreadystatechange = callback;
        
        //Initializes the request object with GET (METHOD of posting),
        //Request URL and sets the request as asynchronous.
        //xmlHttp.open(mthod, url, true);
        xmlHttp.open(mthod, url, true);

        //Sends the request to server
        xmlHttp.send(param);
    }
}