Long Polling Javascript
Long Polling Javascript
v=rQ46mQjLVyI
https://code-boxx.com/ajax-long-polling-php-mysql/
TABLE OF CONTENTS
Extras
The End
DOWNLOAD & NOTES
Here is the download link to the example code, so you don’t have to
copy-paste everything.
All right, let us now get into an example of AJAX long polling a live
game score using PHP MySQL.
For a start, this simple table will store the game scores.
"mysql:host=".DB_HOST.";dbname=".DB_NAME.";charset=".DB
_CHARSET,
DB_USER, DB_PASSWORD, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
]);
}
<script>
// (B) LAST UPDATED TIMESTAMP
var last = 0;
// (D) GO!
window.onload = poll;
</script>
EXTRAS
That’s all for this guide, and here is a small section on some extras
and links that may be useful to you.
PUSH NOTIFICATIONS
Also, times have changed. We no longer live in the Stone Age of
the Internet, and there is something called “push notification”. Yep,
this makes a lot more sense when pushing out updates and news.
Check out the links below for more examples of push and
WebSockets.
THE END
Thank you for reading, and we have come to the end of this guide. I
hope that it has helped you with your project, and if you want to
share anything with this guide, please feel free to comment below.
Good luck and happy coding!
1. Pusher
2. Ably
3.