|
$(function () {
// Reference the auto-generated proxy for the hub.
var chat = $.connection.chatHub;
// Create a function that the hub can call back to display messages.
chat.client.addNewMessageToPage = function (name, message) {
// Add the message to the page.
$('#discussion').append('<li><strong>' + htmlEncode(name)
+ '</strong>: ' + htmlEncode(message) + '</li>');
$.ajax({ // use ajax to get the value
type: "POST",
url: "Value",
async: false,
dataType: "json",
contentType: "text/plain",
success: function (data) {
debugger
var progress = $("#rtlBar").data("ejProgressBar");
progress.setModel({ value: data + " %" });
progress.setModel({ text: data + " %" });
},
error: function () {
alert('Error Loading Data');
},
});
};
// Get the user name and store it to prepend to messages.
$('#displayname').val(prompt('Enter your name:', ''));
// Set initial focus to message input box.
$('#message').focus();
// Start the connection.
$.connection.hub.start().done(function () {
$('#sendmessage').click(function () {
// Call the Send method on the hub.
chat.server.send($('#displayname').val(), $('#message').val());
// Clear text box and reset focus for next comment.
$('#message').val('').focus();
});
});
});
[controller]
[HttpPost]
public ActionResult Value()
{
return Content("90"); // to send the data to the ajax method
} |