Created
April 22, 2015 23:33
-
-
Save toinetoine/37e243f5bf5a294cfe37 to your computer and use it in GitHub Desktop.
HTML page from SignalR tutorial at http://www.antoinedahan.com/blog/SignalRAzureTutorial/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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