For activating the callback mechanism, you need to define the following methods in your javascript as callbacks:
function onOpen(data){
alert("Connection opened");
}
function onMessage(data){
alert("Message recieved!");
}
function onMessageSent(data){
alert("Message Sent!");
}
function onClose(data){
alert("Connection closed");
}
function onError(data){
alert("Error");
}
function onHistoryReceived(data){
alert("Recieved History");
}