チャットを作成するために SignalR を使用しています。完全に機能しますが、マスターページで使用すると次のエラーが発生します
Uncaught TypeError: Cannot read property 'chat' of undefined
(anonymous function)
fire
self.fireWith
jQuery.extend.ready
DOMContentLoaded
エラーは次の場所にあります。
<script type="text/javascript">
$(function () {
var chat = $.connection.chat;
**Uncaught TypeError: Cannot read property 'chat' of undefined**
$.connection.hub.start({ transport: 'auto' }, function () {
//alert('connected');
$('#MainContent_connected').text('Connected to chat room');
});
$("#broadcast").click(function () {
chat.send($("#MainContent_userName").text() + $("#msg").val());
$("#msg").val('')
});
/* Declaring the Function on the chat hub in order for the server to
be able to invoke it. */
chat.addMessage = function (message) {
$('#messages').append('<li>' + message + '</li>');
};
});
</script>
これを修正する方法について何か考えはありますか?