11.07.2015 Views

AJAX and PHP

AJAX and PHP

AJAX and PHP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}}// retrieve the arrays from the server's responseidArray = response.getElementsByTagName("id");colorArray = response.getElementsByTagName("color");nameArray = response.getElementsByTagName("name");timeArray = response.getElementsByTagName("time");messageArray = response.getElementsByTagName("message");// add the new messages to the chat windowdisplayMessages(idArray, colorArray, nameArray, timeArray,messageArray);// the ID of the last received message is stored locallyif(idArray.length>0)lastMessageID = idArray.item(idArray.length - 1).firstChild.data;// restart sequencesetTimeout("requestNewMessages();", updateInterval);Chapter 5/* function that appends the new messages to the chat list */function displayMessages(idArray, colorArray, nameArray,timeArray, messageArray){// each loop adds a new messagefor(var i=0; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!