Javascript 事件处理程序不使用jQuery

Javascript 事件处理程序不使用jQuery,javascript,jquery,ajax,json,event-handling,Javascript,Jquery,Ajax,Json,Event Handling,我正在做一个类似于Facebook或Gmail的聊天,但有些东西不起作用。如果我打开了5个对话,只有一个有效,只有一个显示/隐藏。你可以从中看到它。如果我粘贴一段代码是没有用的,因为它涉及所有内容,我需要粘贴我的所有站点 但这里有一些聊天代码 function getOnJSON(){ var from;var to;var msg_id;var msg_txt;var new_chat_string; //Getting the data from the json file

我正在做一个类似于Facebook或Gmail的聊天,但有些东西不起作用。如果我打开了5个对话,只有一个有效,只有一个显示/隐藏。你可以从中看到它。如果我粘贴一段代码是没有用的,因为它涉及所有内容,我需要粘贴我的所有站点

但这里有一些聊天代码

function getOnJSON(){
    var from;var to;var msg_id;var msg_txt;var new_chat_string;

    //Getting the data from the json file
    $.getJSON("/ajax/end.emu.php",function(data){
    $.each(data.notif, function(i,data){
        from = data.from;to = data.to;msg_id = data.id;msg_txt = data.text;
        if ($("#chat_"+from+"").length === 0){
            $("#boxes").append('<div id="chat_'+from+'" class="chat_box hidden_box">'+
                '<div id="'+from+'_nick" class="chat_nick">'+from+'</div>'+
                '<ul id="'+from+'_txt" class="chat_txt">'+
                    '<li id="'+msg_id+'_txt_msg" class="chat_txt_msg">'+ msg_txt+'</li>'+
                '</ul>'+
                '<form class="new_message" method="POST" id="new_msg_'+from+'">'+
                    '<input type="text" placeholder="Enter your message..." id="'+from+'_input" class="new_input" name="post_text" />'+
                    '<input type="hidden" name="to" value="'+from+'" />'+
                        '</form>'+
                        '</div>');    
            $('#new_msg_'+from).submit(submitChatMsg);
            $('#'+from+'_txt').jScrollPane({stickToBottom: true});
            $('#'+from+'_nick').live("click", function(){ toggleChat('#chat_'+from); });
            // $('#boxes').delegate('.chat_nick', 'click', function() { toggleChat('#chat_'+this.id.replace('_nick', '')); });
            $('body').append('<embed src="http://cdn.live-pin.com/assets/pling.mp3" autostart="true" hidden="true" loop="false">');

        }else{
            var pane2api = $('#'+from+'_txt').data('jsp');
            var originalContent = pane2api.getContentPane().html();
            pane2api.getContentPane().append('<li id="'+msg_id+'_txt_msg" class="chat_txt_msg">'+ msg_txt+'</li>');
            pane2api.reinitialise();
                $('embed').remove();
            $('body').append('<embed src="http://cdn.live-pin.com/assets/pling.mp3" autostart="true" hidden="true" loop="false">');
        }
    });
    });
}

您不能在Firebug中调试javascript并查看发生了什么/出了什么问题?或者你希望其他人为你做这件事?什么事件处理程序?你能把范围缩小到相关代码吗?@KlausByskovHoffmann我做到了,但不起作用@路易斯:我看不到任何地方有人叫我切换聊天,也看不到任何地方有新的表单。@Heera-GUY!异常请把它作为回答,这样我就可以给你分数了,以前没有人可以这样做。你现在能帮我解决表格问题吗?PS:我用
$('.chat_-nick').live('click',function(e){toggleChat('chat_'+this.id.replace('u-nick','');})修复了它
$('.new_message').live('submit',function(){
    contactForm = $(this);
    valor = $(this + 'input:text').val();
    destinatary = $(this + 'input[type=hidden]').val();
    reponse_id = destinatary + "_input";
    if (!$(this + 'input:text').val()) {
        return false;
    } else {
        $.ajax({
            url: "/ajax/end.emu.php?ajax=true",
            type: contactForm.attr('method'),
            data: contactForm.serialize(),
            // success: submitFinished
            success: function(data){
                responsed = $.trim(data);
                if (responsed != "success") {
                    alert("An error occured while posting your message");
                }else{
                    $('#' + reponse_id).val("");
                }
            }
        });
        return false;
    }

});
        $('.chatBox').live('click', function(e){ toggleChat($(this)); });
        function toggleChat(obj)
        {
            current_margin = obj.css('bottom');
            if (current_margin == "0px"){
                obj.animate({bottom : "-270px"});
            }
            else
            {
                obj.animate({bottom : "0px"});
            }
        }