Jump to content

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

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.