var client = new APE.Client(); client.load(); client.addEvent('load', function() { posted_by = prompt('Your name?'); client.core.start({"name": posted_by}); $("input[name='posted_by']").val(posted_by); }); client.addEvent('ready', function() { //Once APE is ready, join the messages channel and wait for new messages client.core.join('messages'); client.onRaw('postmsg', function(raw, pipe) { append_message(raw.data); }); }); function append_message(data) { message_str = data.msg + '\nPosted by: ' + data.posted_by + ' on: ' + data.timestamp; new_div = $('
').addClass('message').html(message_str); $('div#current_messages').append(new_div); }