所以我有一个用 php 和 jquery 构建的聊天室网站,但它使用 2 个不同版本的 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';
}
});
});
有人可以帮我吗,我已经尝试了很长时间,我将不胜感激