Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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>
- }
Add Comment
Please, Sign In to add comment