Another minor thing.
If nothing is returned, you should return the Xml with an empty root node of <events />
This will avoid invalid Xml errors being silently thrown in the JavaScript.
Simply change this in the .php file:
PHP Code:
if ( $output )
{
echo "<events>$output</events>";
}
to
PHP Code:
if ( $output )
{
echo "<events>$output</events>";
} else {
echo "<events />";
}
And because that will now prevent the JavaScript exception, change this in the va_spy.js file:
Code:
try {
events = request.responseXML.getElementsByTagName("events")[0];
event = events.getElementsByTagName("event");
}
catch (e) {
setTimeout("getXML()", 5000);
return;
}
to
Code:
try {
events = request.responseXML.getElementsByTagName("events")[0];
event = events.getElementsByTagName("event");
if (event.length == 0) {
setTimeout("getXML()", 5000);
return;
}
}
catch (e) {
setTimeout("getXML()", 5000);
return;
}
We'll actually never use that catch statement now, but no harm in being extra defensive and leaving it in there