Jump to content

Refresh problems


bPHP

Recommended Posts

Hi! I'm pretty new to Ajax, and I'm creating a web chat. I have a <div> inside my main chat.php that is being refreshed every time. It is something like this:

 

<div class="box" id="chatWindow">
		<div id = "moniter">
		</div>
	</div>

 

The moniter function is refreshing, by using something like this inside a JS file:

 

function moniter()
{
    xmlHttp_moniter = GetXmlHttpObject_parcel()
    if(xmlHttp_moniter == null)
    {
        alert("browser does not support HTTP Request")
        return
    }
    var url="moniter.php?random=" + 23 //This is set to date time actually, but I was doing some changes.
    xmlHttp_moniter.onreadystatechange = stateChanged
    xmlHttp_moniter.open("GET",url,true)
    xmlHttp_moniter.send(null)

}

 

The php then loads all the divs, it first goes to the db, reads all messages and displays them accordingly inside the chat box (adding divs with the nicknames of the people).

 

My main problem is that this is constantly refreshing, so it is impossible to copy text from the chatbox (for example if the user wants to show his/her conversation to someone else, can't do any copying because the refresh does not allow him/her to do it).

 

How can I solve this?

 

Thanks very much!

Link to comment
https://forums.phpfreaks.com/topic/194161-refresh-problems/
Share on other sites

How can i do a div ajax refresh based not on timing but on a condition? For example if an sql table was updated? I don't really know how to do this, if someone can give me some insight on how to properly design this... I have a php that calls a JS function using Ajax and loads from another php after x seconds... I would like this to be based on a condition but I'm really lost... Any help or suggestions will be appreciated!

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/194161-refresh-problems/#findComment-1022482
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.