Skip to content

Instantly share code, notes, and snippets.

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 hbulens/feab1c8153a3a72d04d341f887788b86 to your computer and use it in GitHub Desktop.
Save hbulens/feab1c8153a3a72d04d341f887788b86 to your computer and use it in GitHub Desktop.
<div class="row">
<div class="col-md-12">
<div id="messagesTable">
</div>
</div>
</div>
@section scripts
{
<script src="~/Scripts/jquery.signalR-2.2.0.min.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="~/signalr/hubs"></script>
<script type="text/javascript">
var link = '@Url.Action("GetMessages", "Home")';
$(function () {
// Declare a proxy to reference the hub. v
var notifications = $.connection.chatHub;
// Create a function that the hub can call to broadcast messages.
notifications.client.updateMessages = function () { getAllMessages() };
// Start the connection.
$.connection.hub.start()
.done(function () { getAllMessages(); })
.fail(function (e) { alert(e); }); });
function getAllMessages() {
var tbl = $('#messagesTable');
$.ajax({
cache: false,
url: link,
dataType: "json",
type: 'GET'
})
.success(function (data) {
var array = String(data).split(",");
tbl.empty()
for (var i in array) {
tbl.append('<div>Insurer: ' + array[i] + '</div>');
}
})
.error(function (response) { alert(response) }); }
</script>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment