Ok Hi Help help help I am having a major problem with setTimeout it is not working and i did everything not working
Bu yüzden (ben 2 tarayıcı pencerelerini açarak test) iletileri göndermek ve almak için gereken bir sohbet sistemi developping am
Here is the code i changed many times I hope any one can help me
javascript
$(document).ready(function()
{
updateMsg();
});
function updateMsg()
{
$.ajax({
url:"db.php",
type:"POST",
success:function(data){
}
});
setTimeout("updateMsg()",7000);
}
function addMessages()
{
$.ajax({
url:"db.php",
type:"POST",
data:"name="+$("#name").val()+"&to="+$("#user2").val()+"& cc="+$("#user").val()+"&msg="+$("#msg").val(),
success:function(data)
{
$("#t1").prepend(data);}
});
}
php
$user_select = mysql_query("SELECT * FROM User WHERE User_name = '$name'")
or die(mysql_error());
$fetch_select = mysql_fetch_array($user_select);
$user_check = mysql_num_rows($user_select);
if(isset($_POST['msg']) && $_POST['msg'] != '')
{
if ($user_check == 0)
{
mysql_query("INSERT INTO User (User_name) VALUES ('$name')") or die(mysql_error());
$new_user = mysql_query("SELECT * FROM User WHERE User_ID = LAST_INSERT_ID()");
$fetch_new_user = mysql_fetch_array($new_user);
mysql_query("INSERT INTO Messages(From_user,Msg_body,Date_Time)
VALUES ('$fetch_new_user[User_ID]','$msg',NOW())") or die(mysql_error());
}
else
{
mysql_query("INSERT INTO Messages(From_user,Msg_body,Date_Time)
VALUES ('$fetch_select[User_ID]','$msg',NOW())") or die(mysql_error());
}
}
$sql = mysql_query("SELECT Msg_body,Date_Time,User_name
FROM Messages,User
WHERE From_user = User_ID
AND Msg_ID = LAST_INSERT_ID()
ORDER BY Date_Time DESC") or die(mysql_error());
while($result = mysql_fetch_array($sql))
{
$mydata = '<tbody id="tbody1">
<tr class="highlight">
<td width="30" id="bullet" align="center">
<a href="#" class="nohighlight">•</a></td>
<td width="30px" align="center" id="replyImg"><input type="image" src="css/images/reply_arrow.png" onClick="reply()"></input></td>
<td width="70" align="Left" id="time">'.$result["Date_Time"].'</td>
<td width="200" align="Left" id="from">'.$result["User_name"].'</td>
<td width="200" align="Left" id="to">'.$result[""].'</td>
<td id="showMsg">'.$result["Msg_body"].'</td>
<td width="200" align="left" id="group">'.$result["Grp_abr"].'</td>
</tr>
</tbody>';
}
echo $mydata;
?>
Teşekkürler çocuklar