xmlhttprequest - mozilla
I've a very frustrating problem trying to fix my code to work in Mozilla. I'd really appreciate help on this as I've not been able to find many samples of posting this to asp page! Here's my problem:-
I've various listboxes on an asp page with each populating the next from a database. Rather than submitting the form each time, the listbox onchange event runs some client side code to grab the form info, load it into as xml, post it to another asp page which then queries the database. The results are returned back as a string and popped back into the relevant listbox. This all works fine in IE but falls down in Mozilla. The error returned is "no element found". Here's my code to post it to the asp page using Mozilla (the IE code is separate):-
xmlhttp.open("POST","http://populatelistbox.asp",false)
strXML = "<criteria>";
strXML = strXML + "<listbox1>" + document.myform.term1.value + "</listbox1>";
strXML = strXML + "<listbox2>" + document.myform.select1.value + "</listbox2>";
strXML = strXML + "<listbox3>" + document.myform.term2.value + "</listbox3>";
strXML = strXML + "</criteria>";
xmlDoc=document.implementation.createDocument(""," ",null);
Document.prototype.loadXML=function(strXML)
{
//create a DOMParser
var objDOMParser = new DOMParser();
var objDoc = objDOMParser.parseFromString(strXML, "text/xml");
}
while (xmlDoc.hasChildNodes())
xmlDoc.removeChild(xmlDoc.lastChild);
//add the nodes from the new document
for (var i=0; i < xmlDoc.childNodes.length; i++)
{
//import the node
var objImportedNode = xmlDoc.importNode(xmlDoc.childNodes[i], true);
//append the child to the current document
xmlDoc.appendChild(objImportedNode);
}
xmlDoc.loadXML(strXML);
xmlhttp.send(xmlDoc);
strResponse = xmlhttp.ResponseText;
----------
so, it doesn't in fact error but just returns a no elements found.
|