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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.