Subject: RE: ?readviewentries and xsl and Mozilla
I have a select field with this in the onchange event:var xmlurl=‘VBalDept?readviewentries&RestrictToCategory=’+this[this.selectedIndex].text+ ‘&count=-1’;
xmlGet(xmlurl, tableResponseHandler)
Here is javascript that is used. I got it from this article:http://devzone.skillfusion.com/ajaxArticle1.php. I get no errors.
var xslurl=‘xsltest2.xsl’;
// Immediately try to load the xsl file asynchronously
var xsldocloaded = false;
var xsldoc;
if (window.XSLTProcessor)
{
// support Mozilla/Gecko based browsers
xsldoc = document.implementation.createDocument("", "", null);
xsldoc.addEventListener("load", onXslLoad, false);
xsldoc.load(xslurl);
}
else if(window.ActiveXObject)
{
// support Windows / ActiveX
xsldoc = new ActiveXObject("Microsoft.XMLDOM");
xsldoc.ondataavailable = onXslLoad;
xsldoc.load(xslurl);
}
function onXslLoad()
{
// flag that the xsl is loaded
xsldocloaded = true;
}
/**
-
Open a connection to the specified URL, which is
-
intended to provide an XML message. No other data is
-
sent to the server. This is the same as calling
-
xmlOpen(“GET”, url, null, responseHandler).
-
@param string url The URL to connect to.
-
@param function responseHandler The Javascript function handling server response.
*/
function xmlGet(url, responseHandler)
{
xmlOpen("GET", url, null, responseHandler);
}
/**
-
Open a connection to the specified URL, which is
-
intended to respond with an XML message.
-
@param string method The connection method; either “GET” or “POST”.
-
@param string url The URL to connect to.
-
@param string toSend The data to send to the server; must be URL encoded.
-
@param function responseHandler The Javascript function handling server response.
*/
function xmlOpen(method, url, toSend, responseHandler)
{
if (window.XMLHttpRequest)
{
// browser has native support for XMLHttpRequest object
req = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
// try XMLHTTP ActiveX (Internet Explorer) version
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if(req)
{
req.onreadystatechange = responseHandler;
req.open(method, url, true);
req.setRequestHeader("content-type","application/x-www-form-urlencoded");
req.send(toSend);
}
else
{
alert('Your browser does not seem to support XMLHttpRequest.');
}
}
function tableResponseHandler()
{
// Make sure the request is loaded (readyState = 4)
if (req.readyState == 4)
{
// Make sure the status is "OK"
if (req.status == 200)
{
// Make sure the XSL document is loaded
if (!xsldocloaded)
{
alert("Unable to transform data. XSL is not yet loaded.");
// break out of the function
return;
}
var swappableSection = document.getElementById("TheList");
if (window.XSLTProcessor)
{
// support Mozilla/Gecko based browsers
var xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsldoc);
var outputXHTML = xsltProcessor.transformToFragment(req.responseXML, document);
swappableSection.innerHTML = "";
swappableSection.appendChild(outputXHTML);
}
else if(window.ActiveXObject)
{
// support Windows/ActiveX enabled browsers
var outputXHTML = req.responseXML.transformNode(xsldoc);
swappableSection.innerHTML = outputXHTML;
}
}
else
{
alert("There was a problem retrieving the XML data:\n" +
req.statusText);
}
}
}