If array returns value 1 display online badge
Briefly

To implement real-time server status badges, use JavaScript and AJAX to send periodic requests to your server to check whether each game server is online or offline. Set up an array of server objects with properties for the server's name and status (1 for online, 0 for offline). Use a JavaScript function to loop through this array, checking each server's status and updating the badge display based on whether the server is online or offline, ensuring dynamic and current UI feedback.
To make the badge update in real-time, you can use JavaScript with AJAX to periodically check the server's online status without needing to reload the page.
You will need an array that contains the server names and their online status. A sample structure may look like this: [{'name': 'Server1', 'status': 1}, {'name': 'Server2', 'status': 0}].
In your JavaScript, you can create a function that queries this data every few seconds and updates the badges accordingly based on the online status.
Using a simple if condition within a loop can help you check the status and set the badge text: if (server.status == 1) { // online badge } else { // offline badge }.
Read at SitePoint Forums | Web Development & Design Community
[
|
]