This is a delegation issue. The button doesn't exist at the time that you try to assign the event handler to it. There are two ways you can handle this. You can either move the click event handler assignment to the addTab()
function, after the code has been appended, or you can change it to this...
$("#pageTab").on("click", "#sendButton", function(){
alert("BEHOLD, I AM ALIVE!!");
});
I'd recommend looking at the documentation for .on()
...
Edit:
As for your data posting issue, try changing the code to this...
$.ajax({
type: "POST",
contentType: "application/json",
accepts: "application/json; charset=utf-8",
url: "/api/support/1",
data: {
action: 'ADD_MESSAGE',
user_id: user_id,
message: message
},
dataType: "json",
success: function(data) {
alert("BEHOLD, I have posted!!");
updateConversation();
}
});
The only significant difference is that it's allowing jQuery to send the data as JSON, rather than you converting it first. Let us know how you get on with that.