Here is what we are trying to do -
We need to uniquely identify each box with an ID into a database. We have switched to the GUID funtion and that works. We've built a script that generates it and we pipe that result into a txt.
We can't seem to find a way to read that value into JS. It becomes an argument to our server. (right now hard coded at 1). We even tried to create a guid.js file that would return the value, but could not get the web page to read that in as script source.
We're a little stuck at the moment trying to solve this. I need a little JS snippet that will return a string that is the GUID that I can tack on as a parameter to a server call using XMLhttpRequest call. We have server that can take the argument on the passed url and return XML. We are happily parsing that XML and all is grand. Just can't get the darned GUID to move through.
Below is the the function - You will notice the boxid=1. That's what we want to make unique to each box.
function poll()
{
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","schedule.php?boxid=1",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
if (xmlDoc.getElementsByTagName("action")[0].childNodes[0].nodeValue == "goto") {
window.location=xmlDoc.getElementsByTagName("url")[0].childNodes[0].nodeValue;
}
if (xmlDoc.getElementsByTagName("action")[0].childNodes[0].nodeValue == "download") {
var fname=xmlDoc.getElementsByTagName("fname")[0].childNodes[0].nodeValue;
xmlhttpdl=new XMLHttpRequest();
xmlhttpdl.open("GET","http://localhost/scripts/download.sh?file="+fname,false);
xmlhttpdl.send();
}
}