Tuesday, September 2, 2008

Ajax Class

//var //xmlHttp = //createXmlHttpRequestObject();
// function //createXmlHttpRequestObject()
// {
// try
// {
// // try to create XMLHttpRequest object
// //xmlHttp = new //XMLHttpRequest();
// }
//catch(e)
//{
// var //XmlHttpVersions = new //Array("MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.5.0", //"MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP");
// for (var i=0; i // {
// try
// {
// // xmlHttp = new //ActiveXObject(//XmlHttpVersions[i]);
// }
//catch (e)
// {}
//}
//}
//if (!//xmlHttp)
// alert("Error creating the //XMLHttpRequest object.");
//else
//return //xmlHttp;
//}
//Pass Your Data in below function
//Url is Url of your Ajax Pages
//TimerFunction function name for if serverbusy then which function called e.g:test()
//TimerDelay is delay calll timer
//Wait Function in server busy mode which image call or text display
//here pass only function name like test not test().and in this funtion put status argument value off and value on
//RequestFor= type charcter which u want which user in AjaxResponse() funtion as per your value call ServerResponse Funtion that will return xmlRootnode
//Now put One Funtion name as exactly=AjaxResponse(RequestFor)
//function AjaxRequest(Url,TimerFunction,TimeDelay,WaitFunction,RequestFor)
//{
// if(//xmlHttp)
//{
// try
//{
// if((//xmlHttp.readyState==0)||(//xmlHttp.readyState==4))
// {
// try
// {
// //xmlHttp.open("GET", Url, true);
//}
// catch(e)
// {
// alert("File not found"+e);
// }
// // state Change Function
// //xmlHttp.onreadystatechange=
// function AjaxStateChange()
// {
// if(//xmlHttp.readyState==1 ||//xmlHttp.readyState==3 || //xmlHttp.readyState==2)
// {
// //If server busy then wait message comes in picture with //body disabled
// setTimeout(""+WaitFunction+"('on')"+"",0);
// }
// else if (//xmlHttp.readyState == 4)
// {
// setTimeout(""+WaitFunction+"('off')"+"",0);
//Now Server not busy and ready with output
// if (//xmlHttp.status == 200)
// {
// try
// {
//Server Response Funtion
// //AjaxResponse(RequestFor);
// }
// catch(e)
// {
// alert("Error reading the response: " + //e.toString());
// }
// }
// else
// {
// alert("There was a problem retrieving the data:\n" //+//xmlHttp.statusText);
// }
// }
// }
// //----------------
// //xmlHttp.send(null);
// }
// else
// {
// setTimeout(""+TimerFunction+"",TimeDelay);
// }
// }
// catch (e)
// {
// alert("Can't connect to server:\n" + e.toString());
// }
//}
//return false;
// }
// function AjaxResponse(RequestFor)
//{
// var //xmlResponse = //xmlHttp.responseXML;

// if (//!xmlResponse || //!xmlResponse.documentElement)
// throw("Invalid XML structure:\n" + //xmlHttp.responseText);
//var rootNodeName = ///xmlResponse.documentElement.nodeName;
//if (rootNodeName == "parsererror")
// throw("Invalid XML structure");
// //xmlRoot = xmlResponse.documentElement;
//GetResponse(//xmlRoot,RequestFor);
//}
//function GetResponse(Root,RequestFor)
//{
// if(RequestFor=='ValueToMatch')
// {
// ServerResponseFunction1(Root);
//}
//else if(RequestFor=='ValueToMatch')
//{
// ServerResponseFunction2(Root);
//}

//}