gpt4 book ai didi

php - 未捕获的异常 : jQuery UI Tabs: Mismatching fragment identifier

转载 作者:可可西里 更新时间:2023-11-01 12:32:56 26 4
gpt4 key购买 nike

全部。我构建了一个运行良好的简单 jQuery/PHP 聊天程序。但是,我想添加 channel 或房间等功能。理想情况下,我想使用聊天顶部的选项卡来管理用户所在的房间(只有 2 个)。我认为这将是一项简单的任务,并且我以前见过类似的事情,但是当单击选项卡时我一直收到未捕获的异常错误,并且源代码没有正确加载。我将发布整个聊天系统的代码,因为我觉得问题可能出在其中。

jquery

page = {
getChat: function() {
$.ajax({
url: 'game_src.php',
data: 'mode=getChat',
dataType: 'html',
cache: false,
success: function(res){
$("#chatbox").html(res);
}
});
}
};

$("#submitmsg").click(function(){
var clientmsg = $("#usermsg").val();
$.ajax({
url : 'game_src.php',
data: 'mode=chatSubmit&msg=' + encodeURIComponent(clientmsg)
});
$("#usermsg").attr("value", "");
return false;
});

setInterval(page.getChat, 4000);

$("#chatChannel").tabs({
cookie: { expires: 1 },
});

聊天正文

<?php
if($user->data['user_id'] == ANONYMOUS)
{

}
else
{
?>
<div id="chatChannel">
<ul>
<li><a href="#global">Global</a></li>
<li><a href="#alli">Alliance</a></li>
</ul>
</div>
<form name="message" action="">
<input name="usermsg" type="text" id="usermsg" size="25" />
<input name="submitmsg" type="submit" id="submitmsg" value="Send" />
</form>
<br />
<?php
}
?>
<div id="chatbox" style="border:1px solid black;background-color: rgba(255,255,255,0.3);height:400px;overflow:auto;">
<div id="global">
<?php
$chatMsgs = array();
$limit = time()-86400;

$sql = 'SELECT COUNT(chat_id) as count FROM '.CHAT_TABLE.' WHERE chat_channel = 0 AND chat_time > '.$limit;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$count = $row['count'];

if($count > 0)
{
$sql = 'SELECT * FROM '.CHAT_TABLE.' WHERE chat_channel = 0 AND chat_time > '.$limit.' ORDER BY chat_time DESC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$chatMsgs[] = array(
'chat_time' => $row['chat_time'],
'chat_msg' => $row['chat_msg'],
'chat_user' => $row['chat_user'],
'chat_channel' => $row['chat_channel']
);
}

foreach($chatMsgs as $msg)
{
$sql = 'SELECT username FROM '.USERS_TABLE.' WHERE user_id = '.$msg['chat_user'];
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$username = $row['username'];

echo '<div class="chatMsg" style="border-bottom:1px solid black;">';
echo '<div class="chatUsr">'.$username.' says:</div>';
echo '<div class="chatUsrMsg" style="float:left;">'.$msg['chat_msg'].'</div>';
echo '<div class="chatMsgTime" style="float:right;">'.date("g:i a", $msg['chat_time']).'</div>';
echo '</div>';
echo '<br />';
echo '<hr />';
}
}
else
{
echo '<div class="chatMsg">Nothing is heard but the sound of crickets...</div>';
}
?>
</div>
<div id="alli">
<?php
$chatMsgs = array();
$limit = time()-86400;

$sql = 'SELECT COUNT(chat_id) as count FROM '.CHAT_TABLE.' WHERE chat_channel = 1 AND chat_time > '.$limit;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$count = $row['count'];

if($count > 0)
{
$sql = 'SELECT * FROM '.CHAT_TABLE.' WHERE chat_channel = 1 AND chat_time > '.$limit.' ORDER BY chat_time DESC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$chatMsgs[] = array(
'chat_time' => $row['chat_time'],
'chat_msg' => $row['chat_msg'],
'chat_user' => $row['chat_user'],
'chat_channel' => $row['chat_channel']
);
}

foreach($chatMsgs as $msg)
{
$sql = 'SELECT username FROM '.USERS_TABLE.' WHERE user_id = '.$msg['chat_user'];
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$username = $row['username'];

echo '<div class="chatMsg" style="border-bottom:1px solid black;">';
echo '<div class="chatUsr">'.$username.' says:</div>';
echo '<div class="chatUsrMsg" style="float:left;">'.$msg['chat_msg'].'</div>';
echo '<div class="chatMsgTime" style="float:right;">'.date("g:i a", $msg['chat_time']).'</div>';
echo '</div>';
echo '<br />';
echo '<hr />';
}
}
else
{
echo '<div class="chatMsg">Nothing is heard but the sound of crickets...</div>';
}
?>
</div>
</div>

我将向 getChat jquery 函数添加一个参数来来回切换,但是我所拥有的东西让我卡住了。谁能指出我正确的方向?

最佳答案

JQuery UI 选项卡插件期望内容 div 与链接的 ul 位于同一容器中。

在您的例子中,它希望内容 div 位于 ul 正下方的 div id="chatChannel" 中,但是他们不在那里。

关于php - 未捕获的异常 : jQuery UI Tabs: Mismatching fragment identifier,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9640435/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com