为什么我在使用Signal R技术使用自动刷新获取数据时出错? [英] Why I am getting error on fetching data with autorefresh using Signal R Technology?
问题描述
为什么我使用Signal R技术获取使用autorefresh获取数据的错误?
我在获取时出错使用Signal R技术进行autorefresh的数据
我正在使用VS 2010(Framework 4.0)与asp.net。我这样做是指链接
http://techbrij.com/database-change-notifications-asp-net-signalr-sqldependency
Why I am getting the error on fetching data with autorefresh using Signal R Technology?
I am getting the error on fetching data with autorefresh using Signal R Technology
I am using VS 2010(Framework 4.0) with asp.net. I did so refering the link
http://techbrij.com/database-change-notifications-asp-net-signalr-sqldependency
<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() {
alert("a");
var $tbl = $('#tblJobInfo');
$.ajax({
url: 'GridScore.aspx/GetScoresTable',
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>
<div>
<table id="tblJobInfo" style="text-align:center;margin-left:10px">
</table>
</div>
<form id="form1" runat="server">
<asp:GridView ID="GridViewScores" runat="server">
</asp:GridView>
<p>
</p>
<h3>View this page with multiple browsers to see how SignalR works!</h3>
</form>
。
错误如下:
无法加载资源:服务器响应状态为404(未找到)http:// localhost:1861 / signalsr / hubs
Un catchError:无法读取未定义的属性'client'
.
Error is as below:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:1861/signalr/hubs
Uncaught TypeError: Cannot read property 'client' of undefined
推荐答案
(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(){
alert(a);
var
.connection.hub.start(); getData(); }); function getData() { alert("a"); var
这篇关于为什么我在使用Signal R技术使用自动刷新获取数据时出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!