- This topic has 1 reply, 2 voices, and was last updated 15 years, 4 months ago by support-joy.
-
AuthorPosts
-
bipien@yahoo.comMember// ajax.js
// newFunction
function newXMLHttpRequest()
{
var xmlreq = false;
// Create XMLHttpRequest object in non-Microsoft browsers
if (window.XMLHttpRequest)
{
xmlreq = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{//else if S
try
{
// Try to create XMLHttpRequest in later versions
// of Internet Explorer
xmlreq = new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch (e1)
{//catch S
// Failed to create required ActiveXObject
try
{
// Try version supported by older versions
// of Internet Explorer
xmlreq = new ActiveXObject(“Microsoft.XMLHTTP”);
}
catch (e2)
{
// Unable to create an XMLHttpRequest by any means
xmlreq = false;
}
}//catch E
}//else if E
return xmlreq;
}
/*
* Returns a function that waits for the specified XMLHttpRequest
* to complete, then passes it XML response to the given handler function.
* req – The XMLHttpRequest whose state is changing
* responseXmlHandler – Function to pass the XML response to
*/
function getReadyStateHandler(req, responseXmlHandler) {
return function () // Return an anonymous function that listens to the XMLHttpRequest instance
{
if (req.readyState == 4)
{
if (req.status == 200)
{
responseXmlHandler(req.responseXML);
} else
{
alert(“HTTP error “+req.status+”: “+req.statusText);
}
}
}
}
// flight definition.js
function getSubType(frm, value)
{
var httpRequest = newXMLHttpRequest();
httpRequest.onreadystatechange = getReadyStateHandler(httpRequest, updateSubTypeList);
httpRequest.open(“POST”,”ajax?subAction=SubTypes”, true);
httpRequest.setRequestHeader(“Content-Type”, “application/x-www-form-urlencoded; charset=UTF-8”);
httpRequest.send(“type=”+value);
}
function List(xmlMessage)
{
try
{
var subType = document.getElementById(‘SubType’);
initializeSelect(subType,false);
xmlMessage=xmlMessage.getElementsByTagName(“XML-MESSAGE”)[0];
var status = xmlMessage.getElementsByTagName(“STATUS”)[0].firstChild.data;
if(status==’SUCCESS’)
{
var subTypeList = xmlMessage.getElementsByTagName(“SUB-TYPE-LIST”)[0].getElementsByTagName(“SUB-TYPE”);
for(var i=0;i<subTypeList.length;i++)
{
subTypeList[i].getElementsByTagName(“TYPE-DESCRIPTION”)[0].firstChild.data;
subTypeList[i].getElementsByTagName(“TYPE”)[0].firstChild.data;
}
}
else if(status==’FAILURE’)
{
alert(xmlMessage.getElementsByTagName(“MESSAGE”)[0].firstChild.data);
}
}
catch(e)
{
alert(“Problem in handling request “+e);
}document.setContentType(“application/xml”);
document.getWriter().write(xmlMessage);
document.getWriter().flush();
document.flushBuffer();
return null;
}
support-joyMemberI see that you have created a lot of posts with source code. It will be much better if you cross post your code to relevant forums.
-
AuthorPosts