Moin,
Also JS-Code:
JavaScript
function WholemealShout(shoutbox_content_id, shoutbox_input_form_id, shoutbox_bmsg_id){ var content_div = document.getElementById(shoutbox_content_id); var input_form = document.getElementById(shoutbox_input_form_id); var bot_span = document.getElementById(shoutbox_bmsg_id); var req = null; this.autorefresh = null; this.getXmlHttpRequest = function(){ if (window.XMLHttpRequest) { httpReq = new XMLHttpRequest(); } else if (typeof ActiveXObject != "undefined") { httpReq = ActiveXObject("Microsoft.XMLHTTP"); } return httpReq; } this.show = function(all){ all = all || 0; req = this.getXmlHttpRequest(); req.onreadystatechange = this.response_chat_xml; if(all==0){ req.open("GET", "WholemealShout.php?all=0", true); } else if(all == 1){ req.open("GET", "WholemealShout.php?all=1", true); } req.send(null); return null; } this.response_chat_xml = function(){ if(req.readyState == 4){ xml = req.responseXML; msg_length = xml.getElementsByTagName("msg").length; content = ""; i = 0; while(i<msg_length){ content += "<p>"+xml.getElementsByTagName("msg")[i].firstChild.data+"</p>"; i++; } content_div.innerHTML += content; if(xml.getElementsByTagName("aref") != null){ button = "<input type=\"button\" onclick=\"show()\" name=\"chat_act\" id=\"chat_act\" value=\"Aktualisieren\">"; input_form.innerHTML += button; } if(xml.getElementsByTagName("bmsg") != null){ bot = xml.getElementsByTagName("bmsg").firstChild.data; bot_span.innerHTML += bot; } req = null; } if(this.autorefresh == true){ setInterval(this.show, 300); } return null; } } var WholemealShout = new WholemealShout("shoutbox_content", "shoutbox_input_form", "shoutbox_bmsg"); WholemealShout.show(1);
und zurückgebebene XML-Datei:
XML
<wholemealshout>
<msg>BOT(18:46): Willkormmen!
</msg>
<msg>adsa(01:00): Moin</msg>
</wholemealshout>
Angezeigt wird nachtürlich nix und wenn man nach der for-schleife ein alert setzt wird das auch nicht ausgeben...
thx