Skip to content

Instantly share code, notes, and snippets.

@toinetoine
Created April 22, 2015 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toinetoine/37e243f5bf5a294cfe37 to your computer and use it in GitHub Desktop.
Save toinetoine/37e243f5bf5a294cfe37 to your computer and use it in GitHub Desktop.
HTML page from SignalR tutorial at http://www.antoinedahan.com/blog/SignalRAzureTutorial/
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Our Example Page for SignalR</title>
<!-- js files to include for SignalR-->
<script type="text/javascript" src="Scripts/jquery-2.1.3.min.js"></script>
<script src="Scripts/jquery.signalR-2.1.2.min.js"></script>
<script src="signalr/hubs"></script>
</head>
<body>
<div>
<h3>Input some text to share will all other clients using this web page now. </h3>
<input id="my-text" type="text" />
<button id="submit-my-text">Submit</button>
</div>
<div id="all-comments"></div>
<script>
$(function () {
var commentHub = $.connection.exampleHub;
commentHub.client.AddCommentLocal = function (newComment) {
$("#all-comments").append("<div>" + newComment + "</div>");
};
$.connection.hub.start().done(function () {
$('#submit-my-text').click(function () {
// Send your comment to the Hub
commentHub.server.addCommentToServer($('#my-text').val());
//clear the textbox
$("#my-text").val("");
});
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment