View Single Post
Old 12-13-2012, 05:02 PM   PM User | #9
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
.. but you are not waiting for the ajax-request to complete:

Code:
xmlhttp.open("GET","secretlink=xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
..so none of this may work anyway!?

Code:
xmlhttp.onreadystatechange = processXML;
xmlhttp.open("GET","secretlink=xml",false);
xmlhttp.send();

function processXML() {
    if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
        var i = 0, d, xmlBodyN, xmlCreate, newCreate, jsDate;
        xmlDoc = xmlhttp.responseXML;
        while (d = document.getElementById("Body" + i)) {
            xmlBodyN = xmlDoc.getElementsByTagName("Body")[i];
            if (xmlBodyN) {
                d.innerHTML = xmlBodyN.childNodes[0].nodeValue;
                xmlCreate = xmlDoc.getElementsByTagName("Created")[i];
                if (!xmlCreate) continue;
                newCreate = document.createElement('span');
                newCreate.id = "Timestamp" + i++;
                d.parent.insertBefore(newCreate, d);

                xmlCreate = xmlCreate.childNodes[0].nodeValue;
                jsDate = new Date(xmlCreate);
                jsDate = jsDate.format('mmmm dxx, h:nnap');
                newCreate.innerHTML = jsDate;
            } else {
                break;
            }
        }
    } else {
        // Doh! Couldn't get data..
    }
}
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS

Last edited by AndrewGSW; 12-13-2012 at 05:11 PM..
AndrewGSW is offline   Reply With Quote