我需要帮助将jQuery1.3代码转换为jQuery2.2.2

我需要帮助将jQuery1.3代码转换为jQuery2.2.2,jquery,jquery-1.3,Jquery,Jquery 1.3,所以我有一个聊天室网站是用php和jquery构建的,但是它使用了两个不同版本的jquery,我添加的一些新页面相互冲突 (尽管我在其他页面上同时链接了两个jquery版本)因此我需要帮助转换代码,因为我不知道什么是折旧的,这里没有的是我的jquery 1.3代码 // jQuery Document $(document).ready(function() { //If user submits the form $("#submitmsg").

所以我有一个聊天室网站是用php和jquery构建的,但是它使用了两个不同版本的jquery,我添加的一些新页面相互冲突 (尽管我在其他页面上同时链接了两个jquery版本)因此我需要帮助转换代码,因为我不知道什么是折旧的,这里没有的是我的jquery 1.3代码

    // jQuery Document
    $(document).ready(function() {
        //If user submits the form
        $("#submitmsg").click(function() {
            var clientmsg = $("#usermsg").val();
            $.post("/chatPost/defaultchatpost.php", {
                text: clientmsg
            });
            $("#usermsg").attr("value", "");
            return false;
        });
        //Load the file containing the chat log
        function loadLog() {
            var oldscrollHeight = $("#chatbox").attr("scrollHeight") - 20;
            $.ajax({
                url: "/chatLogs/defaultchatlog.html",
                cache: false,
                success: function(html) {
                    $("#chatbox").html(html); //Insert chat log into the #chatbox  div
                    var newscrollHeight = $("#chatbox").attr("scrollHeight") - 20;
                    if (newscrollHeight > oldscrollHeight) {
                        $("#chatbox").animate({
                            scrollTop: newscrollHeight
                        }, 'normal'); //Autoscroll to bottom of div
                    }
                },
            });
        }
        setInterval(loadLog, 500); //Reload file every 2.5 seconds
        //If user wants to end session
        $("#exit").click(function() {
            var exit = confirm("Are you sure you want to end the session?");
            if (exit == true) {
                window.location = 'defaultchat.php?logout=true';
            }
        });
    });

有人能帮我吗?如果我很长时间都在努力解决这个问题,我将不胜感激。

您似乎试图使用ajax html从主界面调用/chatLogs/defaultchatlog.html。在这种情况下,您不必在defaultchatlog.html中添加jquery,甚至在其他称为html的ajax文件中也是如此。所有函数必须位于主UI中,而不是通过ajax html调用的部分html文件中。例如:main.html和defaultchatlog.html。。。我希望这有帮助

main.html

<html>
    <head>
        <scrpt src="jquery.js"></script>
    </head>
    <body>
        <div id="chatWindows"></div>
    </body>
    <script>
        $(document).ready(function(){
            $.ajax({
            url: "chatlog.html",
            cache: false,
            success: function(html) {
                $("#chatWindows").html(html); //Insert chat log into the #chatbox  div
            },
        });
        });
        function clearLogs(){
            $("#logs").empty();
        }
    </script>
</html>

chatlog.html

<div>
    <ul id="logs">
        <li>Hi</li>
    </ul>
    <button onclick="clearLogs();">Clear</button>
</div>

$(文档).ready(函数(){
$.ajax({
url:“chatlog.html”,
cache:false,
成功:函数(html){
$(“#聊天窗口”).html(html);//将聊天日志插入#聊天盒div
},
});
});
函数clearLogs(){
$(“#日志”).empty();
}
chatlog.html
清楚的
据我所知,jQuery没有什么需要做的,您是否遇到了错误?如果是这样的话,那是什么?我不知道它只是没有用jquery 2.2.2做任何事情。检查文档您在这里没有那么多的函数。如果您点击f12,您在控制台中会出现任何错误吗?您的代码中没有
.live
!代码本身工作正常。问题在别处。对
.live