Posted By:
slaven_miric
Posted On:
Wednesday, June 21, 2006 09:46 AM
Qisland CHAT Hello! I'm started create simple Chat with Ajax! I'm finish basic chat, but they have a problem. When i activate my function timer from onload="getDataFromServer()"> then always a got old XML from server. Under this i think i got XML with data witch was there when i'm inicialize me chat page, although in meantime i set new data to database. When i send new data to server, server insert this data to database and return me again "old" XML. If i turn off timer function, then everything is ok, but always i must click send button to get data from server, and this is not dinamic. And i'm now los
More>>
Qisland CHAT
Hello!
I'm started create simple Chat with Ajax!
I'm finish basic chat, but they have a problem.
When i activate my function timer from
onload="getDataFromServer()"> then always a got old XML from
server. Under this i think i got XML with data witch was there when i'm
inicialize me chat page, although in meantime i set new data to database.
When i send new data to server, server insert this data to
database and return me again "old" XML.
If i turn off timer function, then everything is ok, but always
i must click send button to get data from server, and this is not dinamic.
And i'm now lost!
In this moment chat has two files, index.php and
getdata.php.
Files content:
index.php
=============================================
<?php
$ime = $_POST["nick"];
if (isset($ime)){
echo "
onload="getDataFromServer()">>
color="#ddaaaa"> Wellcom Qisland
Chat!
";
}
else{
echo "
color="#ddaaaa"> Wellcom Qisland
Chat!
";
?>
getdata.php
================================================
<?php
$var1 = $_GET["nickname"];
$var2 = $_GET["speekarea"];
if ($_GET["tip"]){
$var3 = date("H:i");
$var4 = date("Y-n-j");
$baza = mysql_connect('xxx', 'xxx', 'xxx') or die ('Server
sa bazom nije dostupan');
mysql_select_db('xxx') or die ('Greska kod spajanja na bazu
podataka');
$rez = mysql_query("insert into chat values('$var1',
'$var2', '$var3', '$var4')") or die ("Greska kod upisa u bazu (kat
veæ postoji)");
mysql_close($baza);
}
$baza = mysql_connect('xxx', 'xxx', 'xxx') or die ('Server
sa bazom nije dostupan');
mysql_select_db('xxx') or die ('Greska kod spajanja na bazu
podataka');
$rez = mysql_query('select * from chat');
$redovi = mysql_num_rows($rez);
for ($i=0; $i<$redovi; $i++){
$nick = mysql_result($rez, $i, 0);
$red = mysql_result($rez, $i, 1);
echo $nick . ": " . $red . "
";
}
mysql_close($baza);
?>
So if anybody see or know where i'm wrong...
I hope somebody know what is wrong whit this.
Thanks!
Bye!
<<Less