我已經嘗試了所有寫在FAQ它幫助我避免我面臨除了無法讀取屬性的「聊天」的不確定
(Uncaught TypeError: Cannot read property 'chat' of undefined)
這裏的所有問題是我的代碼:
[[
<script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.signalR-1.0.0-rc2.min.js" type="text/javascript"></script>
<script src="~/signalr/hubs" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
// Proxy created on the fly
var chat = $.connection.chat;
// Declare a function on the chat hub so the server can invoke it
chat.client.addMessage = function (message) {
$('#messages').append('<li>' + message + '</li>');
};
// Start the connection
$.connection.hub.start().done(function() {
$("#broadcast").click(function() {
// Call the chat method on the server
chat.server.send($('#msg').val());
});
});
});
]]
你有沒有在你的頁面中包含兩次jQuery? – davidfowl
@Ahmed你能否提供更多的細節?它是Javascript嗎? –
我想,如果你想讓人們幫忙,你將不得不張貼一些代碼。 – Gray