﻿/*
This function will be called by the client page script by passing AjaxInfo object.
AjaxInfo object consists of three properties: 
HttpUrl - Url of the server page (Server page can be a simple page or a generic handler).
AssemblyName - Name of the assembly.
ClassName - Name of the class.
MethodName - The name of the method to be called. This method should be in the server page.
ParameterTypeList - List of parameter types corresponding to method signature. These typenames should be seperated by '|' character.
ParameterValueList - List of parameter values corresponding to method signature. These parameters should be seperated by '|' character. 
*/
function InvokeHttpHandler(ajaxInfo)
{
    //Create the final url from the parameters given by AjaxInfo object.
	var url = ajaxInfo.HttpUrl; 
	url += '?AssemblyName=' + ajaxInfo.AssemblyName;
	url += '&ClassName=' + ajaxInfo.ClassName;
	url += '&MethodName=' + ajaxInfo.MethodName;
	url += '&ParameterTypeList=' + ajaxInfo.ParameterTypeList;
	url += '&ParameterValueList=' + ajaxInfo.ParameterValueList;
	url += '&RKey=' + Math.random();
	//Call the http request to get response.
	var response = GetXmlHttpResponse(url);
	//Return  the response returned by the http request.
    return response;
        
}

/*
This function will create a XMLHttpRequest object and send the request to the server url.
XMLHttpRequest is and generalised http object which is supported by all browsers (test in IE, FF, Opera and Chrome).
*/
function GetXmlHttpResponse(url)
{
    try
    {
        var xmlhttp = new XMLHttpRequest()
        //Open the http channel.
        xmlhttp.open("get",url,false);
        //Send the http request.
        xmlhttp.send(null);
        //return the response of the http request.
        return xmlhttp.responseText;
    }
    catch(e)
    {
        alert(e);
    }
} 

  
