PHP Chat Script - Set Interval

Place for comments, problems, questions, or any issue related to the JavaScript / PHP scripts from this site.
hups
Posts: 7

PHP Chat Script - Set Interval

Hello
In the PHP Chat script from https://coursesweb.net/php-mysql/script-chat-simple_s2 where can i set intervall?

Admin Posts: 805
If you refer to the interval that the Ajax function accesses the php file, modify the number 1900 (milliseconds) to this line of code (line 431) in the chatfunctions.js file.

Code: Select all

setTimeout('apelAjax()', 1900);

hups Posts: 7
ok thanks,
The var callphp is another constant ?

Admin Posts: 805
The callphp variable is used to control when to load the chat data from php or directly from the txt file with chatroom.
Reading a txt file with data in json format uses less resources than accessing the php script.
It is a logic around the callphp var that I implement it to make the script to use less server resources.
The php file is accessed when a new chat message is added, and when the number of online users is changed (to actualize them)

Code: Select all

callphp = 2.8 + (getNrChatUsers() * 0.3);  // sets to call "setchat" according to number of online users
In the rest, chats data are loaded directly from txt file.