Implemented AJAX to send messages to the server