Execute javascript function in php

2

I'm building a chat system in php, and in the onlines client checking function it's going to be an ajax calling a php file every 30s, and in this file there will be a foreach that will bring in each user and do the verification , and I need to make a function that when the client is offline, change the html class in the attendant panel to offline, inside the foreach. That is, for each user he sees that he is offline he would already be setting up inside the foreach that the client is online or ofline changing his class.

Would it be possible to run this JS function within php? or in php call a JS function?

    
asked by anonymous 29.10.2017 / 22:28

1 answer

0

I was able to resolve this as follows, I checked the users that were online in the php file, and after checking I put the id of the users online in an array and returned that array to JS, in js I ran a for for each id of the array marked as online. So I'm making this request every 10 seconds. Thanks to those who helped.

    
05.11.2017 / 17:20