Converted sendMessage POST request to $.ajax