|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<link rel="stylesheet" href="/static/main.css">
|
|
|
|
<script src="/static/jquery-3.3.1.min.js"></script>
|
|
|
|
<title> Yeah! </title>
|
|
|
|
<script type="text/javascript">
|
|
|
|
$("document").ready(function() {
|
|
|
|
// Do something...
|
|
|
|
$("#submit-chat").click(function(){
|
|
|
|
fromDid = '19516025252';
|
|
|
|
inputchat = $("#input-chat").val();
|
|
|
|
$.ajax({
|
|
|
|
method: "POST",
|
|
|
|
url: "/submitMessage",
|
|
|
|
data: { message: inputchat, fromdid: fromDid }
|
|
|
|
}).done(function( msg ) {
|
|
|
|
msgParsed = $.parseJSON(msg);
|
|
|
|
newHTML = '<div id="msg"><span class="chat-from">' + msgParsed.fromdid + '</span>: ' + msgParsed.msg + '</div>';
|
|
|
|
$("#chat-body").append( newHTML );
|
|
|
|
alert(msg);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('#test-ajax').click(function() {
|
|
|
|
$.ajax({
|
|
|
|
url: '/testAjax',
|
|
|
|
type: 'GET',
|
|
|
|
success: function(response) {
|
|
|
|
newHTML = '<div id="msg"><span class="chat-from">SYSTEM</span>: ' + response + '</div>';
|
|
|
|
$("#chat-body").append( newHTML );
|
|
|
|
},
|
|
|
|
error: function(error) {
|
|
|
|
errorHTML = '<div id="msg"><span class="chat-from">SYSTEM</span>: Error ' + error + '</div>';
|
|
|
|
$("#chat-body").append( errorHTML );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1 id="channel-name">(888) 555-1212</h1>
|
|
|
|
<div id="chat">
|
|
|
|
<div id="chat-body">
|
|
|
|
<div id="msg"><span class="chat-from">OPERATOR</span>: Welcome!</div>
|
|
|
|
</div>
|
|
|
|
<div id="chat-input">
|
|
|
|
<input type="text" id="input-chat" />
|
|
|
|
<input type="button" id="submit-chat" value="Send"/>
|
|
|
|
<input type="button" id="test-ajax" value="test ajax"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|