I am using jQuery and trying to load a variable instead of a named XML file. My code is:
$(document).ready(function() {
$('#theForm').ajaxForm(function(responseXML2) {
var myxml = responseXML2;
alert(responseXML2);
displayResult();
});
});
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
alert("loading xmlhttprequest");
xhttp=new XMLHttpRequest();
}
else
{
alert("loading activeX");
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
alert("bottom load");
xhttp.open("GET",dname,false);
xhttp.send();
return xhttp.responseXML;
}
function displayResult()
{
alert("setting vars");
alert("displayResult called");
xml=responseXML2;
alert("xmlDocLoaded");
xsl=loadXMLDoc("xslt-test.xsl");
alert("XSLloaded");
if (window.ActiveXObject)
{
alert("IE");
ex=xml.transformNode(xsl);
document.getElementById("ieiresponse").innerHTML=ex;
}
else if (document.implementation && document.implementation.createDocument)
{
alert("notIE");
xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml,document);
document.getElementById("ieiresponse").appendChild(resultDocument);
}
}
In the above code I want:
//xml=loadXMLDoc(responseXML2); //tried this and the line below, among others
xml=responseXML2;
instead of the file name:
xsl=loadXMLDoc("example.xml");
When I run the code, it works if I name the file, but when I use this variable (which appears in the warnings, therefore it is pulled), it stops the code in the specified line (placing the variable as an xml file)
Any help would be greatly appreciated! Thank you in advance.
Paul source
share