gpt4 book ai didi

asp.net - SignalR 未加载。请确保在 ~/signalr/js 之前引用 jquery.sigalR-x.js

转载 作者:行者123 更新时间:2023-12-02 09:40:09 32 4
gpt4 key购买 nike

我在我的页面中动态引用了以下两个库。当我浏览下面的应用程序时,Chrome 浏览器中没有出现提到的错误。但在 Internet Explorer 中会出现错误。

var signalRLibrary = document.createElement('script');
signalRLibrary.type = "text/javascript";
signalRLibrary.src = 'jquery.signalR-2.1.2.min.js';
document.getElementsByTagName('head')[0].appendChild(signalRLibrary);

var signlaRHub = document.createElement('script');
signlaRHub.type = "text/javascript";
signlaRHub.src = "~/signalr/hubs";
document.getElementsByTagName('head')[0].appendChild(signlaRHub);

在页面加载期间,由于未加载 SignalR,我收到以下错误。请确保在 ~/signalr/js 之前引用 jquery.signalR-x.js。

if (typeof ($.signalR) !== "function") {
throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.");
}

enter image description here enter image description here

最佳答案

A JavaScript client requires references to jQuery and the SignalR core JavaScript file. The jQuery version must be 1.6.4 or major later versions, such as 1.7.2, 1.8.2, or 1.9.1. If you decide to use the generated proxy, you also need a reference to the SignalR generated proxy JavaScript file. The following example shows what the references might look like in an HTML page that uses the generated proxy.

<script src="Scripts/jquery-1.10.2.min.js"></script>
<script src="Scripts/jquery.signalR-2.1.0.min.js"></script>
<script src="signalr/hubs"></script>

These references must be included in this order: jQuery first, SignalR core after that, and SignalR proxies last.
- from ASP.NET SignalR Hubs API Guide - JavaScript Client

您的问题是,不知何故,您加载引用的顺序是错误的。

关于asp.net - SignalR 未加载。请确保在 ~/signalr/js 之前引用 jquery.sigalR-x.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37522489/

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