Jump to content

Refresh whole php page with ajax


ganesanji

Recommended Posts

Hi All,

 

  I am developing a simple Instant Messenger in PHP/MySQL with Ajax. I created one page for displaying online friends list. In that page I need to check the DB for waiting message, if there means it will open a popup chat window. My problem is after sending a message to a person, i need to refresh the friends.php for checking the waiting messages in DB, then it will open the popup chat window in the opposite user side(means with whom i am chatting).

 

If I put meta tag refresh for friends.php page, it every time refresh the friends.php and the popup chat window. It is not good for ajax chat.

 

I need to refresh the friends.php for every 5 seconds to check the DB for waiting message, if exist means , i need to open popup chat window.

 

Anything solution available for this? plz help me....adavanced thanks....

 

here i have given the contents of friends.php page

 

<meta http-equiv="refresh" content="5">

<?php

$sql1 = "SELECT * FROM `messages` WHERE touserID='".$_SESSION['userID']."' AND status='0'";

$query1 = mysql_query($sql1)or die(mysql_error());

while ($res1 = mysql_fetch_array($query1)) {

//echo $res1['sessionID']."<br>";

echo "<script type='text/javascript'>openChat(\"convo.php?sessionID=".$res1['sessionID']."\", \"Convo\");</script>";

}

 

// selects all users

 

//$sql = "SELECT * FROM `users`";

$sql = "SELECT * FROM `users` where online_status='1'";

$query = mysql_query($sql);

?>

 

Here is our 'Friends List':<br />

 

<br />

<?php

//echo all users with chat now links

while($result = mysql_fetch_array($query)) {

echo "<a href='javascript: openChat(\"startchat.php?userID=".$result['userID']."\", \"Convo\")'>".$result['username']."</a> <br>";

}

?>

i hope for greatful help.

 

regards,

Ganesanji

Link to comment
https://forums.phpfreaks.com/topic/135107-refresh-whole-php-page-with-ajax/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.