I'm trying to implement AJAX in a script, and since I am pretty much a neophyte at it, it's not going smoothly and something just isn't working right. I found some javascript on the internet and I'm using it to call a vortex function. The function generates an XML string, which the javascript will then parse and use to dynamically update the page. But the vortex function is not getting called, so I'm doing something wrong. Here is the javascript so far:
<verb noesc><script language="JavaScript"></verb>
function sortDisplay(whichSort) {
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","$url/BuildCellDisplayXML.html",false);
xmlhttp.send();
var xmlDoc=xmlhttp.responseXML;
var txt="";
var x=xmlDoc.getElementsByTagName("Title");
<verb noesc>
for (i=0;i<x.length;i++) {
txt=txt + x[i].childNodes[0].nodeValue;
}
</verb>
}
</script>
The name of the vortex function to call is obviously BuildCellDisplayXML. For right now, I was simply going to display the value of txt somewhere on the page. Eventually it will update an already rendered HTML table. But like I said, the function is not even being called.
Related question... Once the above issue is resolved, I don't quite get how to pass the return value of the function (i.e., the XML string that the function builds) back to the responseXML of the xmlhttp object in the javascript. (I haven't gotten that far!) As I said, the javascript you see is something I just plucked from the internet.
<verb noesc><script language="JavaScript"></verb>
function sortDisplay(whichSort) {
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","$url/BuildCellDisplayXML.html",false);
xmlhttp.send();
var xmlDoc=xmlhttp.responseXML;
var txt="";
var x=xmlDoc.getElementsByTagName("Title");
<verb noesc>
for (i=0;i<x.length;i++) {
txt=txt + x[i].childNodes[0].nodeValue;
}
</verb>
}
</script>
The name of the vortex function to call is obviously BuildCellDisplayXML. For right now, I was simply going to display the value of txt somewhere on the page. Eventually it will update an already rendered HTML table. But like I said, the function is not even being called.
Related question... Once the above issue is resolved, I don't quite get how to pass the return value of the function (i.e., the XML string that the function builds) back to the responseXML of the xmlhttp object in the javascript. (I haven't gotten that far!) As I said, the javascript you see is something I just plucked from the internet.