loading xml from a database to be used in multiple functions

Ninopriolla

New Member
I have a database where i'm using php to randomize the information by ID and send it out via xml. My issue is that I only want to grab the xml once and store it for use in at least 2 functions... one function that runs onload to grab the first line of xml, another that will run every time a button is pressed to access the next line of xml until the end. My 2 functions are loadfirst() and loadnext(). loadfirst() works perfectly, but I'm not sure how to pass the xml data to loadnext(). Right now I'm just using loadfirst() on pageload and loadfirst() on button press, but i end up creating new xml from the database each time which causes randomization issues and is incredibly inefficient. Any help would be appreciated.\[code\]function loadfirst(){downloadUrl ("places.php", function(data) { var i = 0; var xml = data.responseXML; var places = xml.documentElement.getElementsByTagName("place"); var id = places.getAttribute("id"); var name = places.getAttribute("name"); var location = places.getAttribute("location"); var imgpath = places.getAttribute("imgpath"); var tags = places.getAttribute("tags");)};\[/code\]Here is my downloadUrl function.\[code\]function downloadUrl(url, callback) { var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest; request.onreadystatechange = function() { if (request.readyState == 4) { request.onreadystatechange = doNothing; callback(request, request.status); } }; request.open('GET', url, true); request.send(null);}function doNothing() {}\[/code\]loadnext() will be very similar to loadfirst(), I'm just running into issues with passing the xml data so that i can use it without having to access the database again. Thanks.
 
Back
Top