为什么刷新网格时出现错误,以便使用SignalR技术在SQL中使用任何数据插入或更新自动刷新网格? [英] Why there is error on refreshing the grid for auto refreshing the Grid with any data insertion or updation in SQL using SignalR Technology?
本文介绍了为什么刷新网格时出现错误,以便使用SignalR技术在SQL中使用任何数据插入或更新自动刷新网格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法使用SignalR技术在SQL中使用任何数据插入或更新来刷新网格。我提到了以下链接:
http://techbrij.com/database-change-notifications-asp-net-signalr-sqldependency
我做了如下:
I am unable to refresh the Grid with any data insertion or updation in SQL using SignalR Technology. I referred the below link:
http://techbrij.com/database-change-notifications-asp-net-signalr-sqldependency
I have did as follows:
<script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.signalR-1.1.4.js" type="text/javascript"></script>
<script src="/signalr/hubs" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
// Proxy created on the fly
var job = $.connection.scoresHub;
// Declare a function on the score hub so the server can invoke it
job.client.displayStatus = function () {
getData();
};
// Start the connection
$.connection.hub.start();
getData();
});
function getData() {
var $tbl = $('#tblJobInfo');
$.ajax({
url: '../api/values',
type: 'GET',
datatype: 'json',
success: function (data) {
if (data.length > 0) {
$tbl.empty();
$tbl.append(' <tr><th>Job Title</th><th>Published Date</th><th>Expiry Date</th><th>Job Status</th></tr>');
var rows = [];
for (var i = 0; i < data.length; i++) {
rows.push(' <tr><td>' + data[i].JobTitle + '</td><td>' + data[i].PublishedDate + '</td><td>' + data[i].ExpiryDate + '</td><td>' + data[i].JobStatus + '</td></tr>');
}
$tbl.append(rows.join(''));
}
}
});
}
</script>
Hub类如下:
Hub class is as below:
public static void Show()
{
IHubContext context = GlobalHost.ConnectionManager.GetHubContext<ScoresHub>();
context.Clients.All.displayStatus();
}
我收到错误,状态代码为404.在给定的情况下,要设置的网址是多少。我想在没有MVC的情况下这样做。
I a getting the error with status code 404. What is the url to be set in the given case. I want to do this without MVC.
推荐答案
(function(){
//代理创建的代理
var job =
(function () { // Proxy created on the fly var job =
.connection.scoresHub;
//在分数中心声明一个函数,以便服务器可以调用它
job.client.displayStatus = function(){
getData();
};
//启动连接
.connection.scoresHub; // Declare a function on the score hub so the server can invoke it job.client.displayStatus = function () { getData(); }; // Start the connection
.connection.hub.start( );
getData();
});
函数getData(){
var
.connection.hub.start(); getData(); }); function getData() { var
这篇关于为什么刷新网格时出现错误,以便使用SignalR技术在SQL中使用任何数据插入或更新自动刷新网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文