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
<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