GAE channel api parsing onmessage

Dushan

New Member
I am building an app with gae, and using the channel api. \[code\]String message ="<data><title>newMessage</title><message>Hello</message></data>"; channelService.sendMessage(new ChannelMessage(user,message));\[/code\]This string is sent from the java servlet, and on the front end i want to parse it with jquery. This is what i did, but it doesn't work.\[code\]function onSocketMessage(message) { var xml = $.parseXML(message.data), $xml = $( xml ), $title = $xml.find('title'); if($title == "newUser"){ alert($xml.find('message')); }}\[/code\]This is the javascript code which actually works fine.\[code\]var messageXML = ((new DOMParser()).parseFromString(message.data, "text/xml")); var title = messageXML.documentElement.getElementsByTagName("title")[0].firstChild.nodeValue; if(title == "newUser"){ alert(messageXML.documentElement.getElementsByTagName("message")[0].firstChild.nodeValue); }\[/code\]
 
Back
Top