0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法'对话'

时间:2015-05-11 05:18:47

标签: jquery asp.net asp.net-mvc visual-studio-2013

我提到的上述错误提供的帮助很少,但无法解决。

我尝试使用以下网址“http://geekswithblogs.net/dotNETvinz/archive/2014/02/27/asp.net-signalr-building-a-simple-real-time-chat-application.aspx

中提供的示例创建聊天应用程序

cshtml的代码如下。只更改了我的脚本文件夹中的js文件。请帮我解决这个问题

@section scripts{

@Scripts.Render("~/Scripts/jquery-ui-1.8.2.min.js")
@Scripts.Render("~/Scripts/jquery.signalR-2.2.0.min.js")
@Scripts.Render("/signalr/hubs")



<script type="text/javascript">

    $(function () {
        showModalUserNickName();
    });
    function showModalUserNickName() {

        $("#dialog").dialog({

            modal: true,
            buttons: {
                Ok: function () {
                    $(this).dialog("close");
                    startChatHub();
                }
            }
        });
    }
    function startChatHub() {
        var chat = $.connection.chatHub;

        // Get the user name.
        $('#nickname').val($('#nick').val());
        chat.client.differentName = function (name) {
            showModalUserNickName();
            return false;
            // Prompts for different user name
            $('#nickname').val($('#nick').val());
            chat.server.notify($('#nickname').val(), $.connection.hub.id);
        };
        chat.client.online = function (name) {
            // Update list of users
            if (name == $('#nickname').val())
                $('#onlineusers').append('<div class="border" style="color:green">You: ' + name + '</div>');
            else {
                $('#onlineusers').append('<div class="border">' + name + '</div>');
                $("#users").append('<option value="' + name + '">' + name + '</option>');
            }
        };
        chat.client.enters = function (name) {
            $('#chatlog').append('<div style="font-style:italic;"><i>' + name + ' joins the conversation</i></div>');
            $("#users").append('<option value="' + name + '">' + name + '</option>');
            $('#onlineusers').append('<div class="border">' + name + '</div>');
        };
        // Create a function that the hub can call to broadcast chat messages.
        chat.client.broadcastMessage = function (name, message) {
            //Interpret smileys
            message = message.replace(":)", "<img src=\"/images/smile.gif\" class=\"smileys\" />");
            message = message.replace(":D", "<img src=\"/images/laugh.gif\" class=\"smileys\" />");
            message = message.replace(":o", "<img src=\"/images/cool.gif\" class=\"smileys\" />");

            //display the message
            $('#chatlog').append('<div class="border"><span style="color:orange">' + name + '</span>: ' + message + '</div>');
        };
        chat.client.disconnected = function (name) {
            //Calls when someone leaves the page
            $('#chatlog').append('<div style="font-style:italic;"><i>' + name + ' leaves the conversation</i></div>');
            $('#onlineusers div').remove(":contains('" + name + "')");
            $("#users option").remove(":contains('" + name + "')");
        }

        // Start the connection.
        $.connection.hub.start().done(function () {
            //Calls the notify method of the server
            chat.server.notify($('#nickname').val(), $.connection.hub.id);
            $('#btnsend').click(function () {
                if ($("#users").val() == "All") {
                    // Call the Send method on the hub.
                    chat.server.send($('#nickname').val(), $('#message').val());
                }
                else {
                    chat.server.sendToSpecific($('#nickname').val(), $('#message').val(), $("#users").val());
                }
                // Clear text box and reset focus for next comment.
                $('#message').val('').focus();
            });

        });
    }
</script>
}







<div id="container">

    <input type="hidden" id="nickname" />
    <div id="chatlog"></div>
    <div id="onlineusers">
        <b>Online Users</b>
    </div>
    <div id="chatarea">
        <div class="messagelog">
            <textarea spellcheck="true" id="message" class="messagebox"></textarea>
        </div>
        <div class="actionpane">
            <input type="button" value="send" id="btnsend" />
        </div>

        <div class="actionpane">
            <select id="users">
                <option vaue="All">All</option>
            </select>
        </div>
    </div>
    <div id="dialog" title="Enter your name to start chat">
        <input type="text" id="nick" />
    </div>
</div>

0 个答案:

没有答案