Easiest Way To Create Realtime Live Notification Count Like Facebook | PHP | AJAX | JAVASCRIPT

preview_player
Показать описание
Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)

Code :-

Subscribe my Channel:-

Facebook Page:-

Twitter Account:-

Blog :-

Hello guys, this is unpossible pog here.
Today, I shall show you the easitest way to display live notification count without refreshing the page like facebook.
As soon as we insert data, the notification count changes which means we no longer have to refresh the page.
I am using the combination of php, javascript and basic ajax.
Let say, if someone likes your photo on facebook, it get stored in database. So in short we have to fetch count of data from database table.
Lets get started.
Here I created one sample page which shows static number of notification so we have to make it dynamic and live.
I created one table in database which represents your notification.
I created one file called “DATA.PHP ” which displays the notification.
But we only want the count so echo the count only.
Now the next task is to access that file in our design page using ajax.
So, create one javascript function and go to google.
Search for ajax code. Go inside w3school site
Copy paste the ajax code.
After the function end, type the function name with rounded brackets and semicolan.
Give an ID to division or any tag that you want.
And copy that same ID in ajax code.
Type the page name here which is connected to database.
Let refresh. And you will see that it is showing the notification count.
Now you have to add function called “SET INTERVAL”, to constantly refresh that ID afer 1 second. Create a function and cut-paste the code inside the curly brackets.
After that we no longer have to refresh page to change notification count.
Lets add some data in table.
Keep looking at notification count.
As soon as we insert data, the notification count changes.
You can give href to that icon to redirect to notification page if you want to.
Thats all for now.
The code is in the description.
Thank you for watching, dont forget to like share and subscribe.
Рекомендации по теме
Комментарии
Автор

I was stuck in this for over 2 days, , but since I watched your tutorial I got it solved.... Great Work! Thanks so much for sharing

josephsigawa
Автор

If a client is performing an action on the web page, e.g form input, the page refresh will be a nuisance for the client. Its better to implement the refresh in a div, using eventlistener ... so that when a new record is inserted, the browser will emit an event listner and refresh in background. This is very easy with laravel livewire . Thanks for educating the young minds BTW ✌

nicolegeorge
Автор

This is really awesome thanks for the knowledge you have shared.

abdallahhamistindwa
Автор

Awesome thank you so much for this best explanation I've found

djyork
Автор

Good tutorial.. very usefull, thanks a lot!

alexanderrio
Автор

Great video, straight to the point and with a real solution. Thank you.

leonelcenteno
Автор

It could be useful tnx and it adds more knowledge for beginners

matthewbriannavarro
Автор

set interval will keep on refershing
if someone want to click it he will be not able to do
it is better to refersh the div after data inserted into database

Abhishekyadav-mopy
Автор

thank you so much, this was easy to understand

Kewledgykid
Автор

make a php, ajax chat room toooo, thankyou I subscribed great vid.

justinguiriba
Автор

how can i embed notify sound also plz reply

VishwasKale
Автор

can you add also an audio during notification sir

WTFMoment
Автор

I have doubt, Once viewed notifications, is set to zero . Pls explain

dineshdd
Автор

Hello. Thank you. If one user read the notification do all next users won't see this notification up please ?

finelarme
Автор

how to show notification in codeigniter please guide me

codewithdhaku
Автор

Useless example. This will create a huge amount of xhr requests per second and make your app slow. Really bad practice, better to use event listeners and use Socket.io or Pusher.

extsania