gpt4 book ai didi

javascript - SignalR 抛出 JavaScript 错误

转载 作者:行者123 更新时间:2023-11-30 07:17:07 25 4
gpt4 key购买 nike

我是信号员的新手。我已经启动了一个开箱即用的 MVC 4.0 应用程序,并在索引 View 上连接了我的信号器 JavaScript。当我单击“注册”或“登录”按钮时,signalr 会抛出一个 JavaScript 错误。

Unhandled exception at line 11, column 10700 in http://localhost:49172/Scripts/jquery.signalR-   0.5.1.min.js

0x800a138f - Microsoft JScript runtime error: Unable to set value of the property 'src': object is null or undefined

任何建议表示赞赏。

编辑:

这是我的代码范围:

$(function () {    
var blasht = $.connection.blashtHub;
blasht.addMessage = function (message) {
$('#messages').append('<li>' + message + '');
};

$("#blashtIt").click(function () {
var control = $('#blashtText');
var control2 = $('#hiddenUserId');
// Call the chat method on the server
blasht.send(control2.val(), control.val());
control.val('');
});

blasht.updateTopTen = function (message) {
//add code to update the top user's list
};

// Start the connection
$.connection.hub.start();
});

按照我的建议,我删除了 min,这是它崩溃的地方,在 frame.sc = src; 上行。

reconnect: function (connection) {
var that = this;
window.setTimeout(function () {
var frame = connection.frame,
src = transportLogic.getUrl(connection, that.name, true) + "&frameId=" + connection.frameId;
connection.log("Upating iframe src to '" + src + "'.");
frame.src = src;
}, connection.reconnectDelay);
},

SignalR,而不是我,正在调用这个重新连接函数。显然,这就是它与服务器保持连接的方式。

最佳答案

这是当前版本的 SignalR 中用于“Forever-Frame”实现的错误,IE9 使用的是: https://github.com/SignalR/SignalR/issues/446

解决方法是强制 SignalR 不使用 Forever-Frame 传输 (https://github.com/SignalR/SignalR/wiki/SignalR-JS-Client)。所以改变

$.connection.hub.start();

$.connection.hub.start({ transport: ['webSockets', 'serverSentEvents', 'longPolling'] });

关于javascript - SignalR 抛出 JavaScript 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11217239/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com