Reputation: 57
so I will try to be as clear as possible on my question!
On my site I have a table with the latest reservations, it's a fetch request that retrieves the data in PHP in JSON format and Javascript that puts them in shape, it works very well. But now I would like to go one step further, and make an automatic system, which would only have the Javascript function to retrieve and format the data. But I would need to do this without having to do a setInterval()
or wait for the user's click, somehow only when a row is added (which is not done by the admin but the system the detect), the array is reloaded. I don't know at all if it's possible or not, and that's why I'm asking here?
(I only work in Javascript with Jquery and with PHP, I don't know if I need another lib?)
Thanks in advance and have a nice day!
Upvotes: 0
Views: 529
Reputation: 36
I think if you use websocket, you can get better system. but, if you can't, I recommend you use setInterval() to check if the row added.
You can install websocket server with nodejs easily. and you have to add send event from php to nodejs ( http ) when new row added in your PHP server. and add javascript websocket client.
Upvotes: 1