Hi, today i am going to tell you about how to display the notification box appear with sound effect like Facebook, we have seen in Facebook at right side we got some posting notifications appear if some one posts, i have did same using jquery, ajax and php with same notification sound, it is very simple logic just need to use some sort of time and it is just few lines of code, lets see how to do this..

HTML
here take the text area box to enter some text, and take one button also, later take one DIV and give it ID name like #alertbox to prepend multiple notifications VIA Ajax<div class="lessoncup"> <textarea id="box" class="box"></textarea> <input value="POST" id="btn" class="btn" type="button" /> <div id="loader"></div> </div> <div id="alertbox"></div>
JAVASCRIPT
write the click function to #btn button as selector, store the text box value in one variable like var post = $('#box').val(); now using ajax request send the post variable to alerts.php file inside the ajax success function prepend the returned message from alerts.php file to #alertbox as a selector using prepend() method, later use the hide the #alerts notification after some time delay using delay() method like this $('#alerts').delay(5000).fadeOut('slow');<script type="text/javascript" src="jquery-1.10.2.min.js"></script> <script> $(document).ready(function(){ $('#btn').click(function(){ var post = $('#box').val(); if(post==""){ alert('enter please'); }else{ $('#loader').fadeIn(400).html('<img src="loader.gif" align="absmiddle"> <span class="loading">sending</span>'); var datasend = "alert="+post; $.ajax({ type:'POST', url:'alerts.php', data:datasend, cache:false, success:function(msg){ $('#box').val(''); $('#loader').hide(); $('#alertbox').fadeIn('slow').prepend(msg); $('#alerts').delay(5000).fadeOut('slow'); } }); } }) }); </script>
alerts.php
in this file just write the query to insert the records and write one more query to fetch the latest record later take a DIV and give a ID name like #alerts inside the div take a AUDIO tag with sound file and put it into autoplay true
<?php include('db.php'); extract($_REQUEST); $h_name=htmlentities($alert); $in_name = mysql_real_escape_string($h_name); mysql_query("insert into alerts(message) values('$in_name')"); $alerts = mysql_query("select * from alerts order by alertId desc"); $full=mysql_fetch_array($alerts); ?> <div id="alerts"> <audio id="audioplayer" autoplay=true> <source src="sound/ping.mp3" type="audio/mpeg"> <source src="sound/ping.ogg" type="audio/ogg"> Your browser does not support the audio element. </audio> <li> <img src="icons/i.jpg" align="top" style="float:left; margin-right:2px;" /> <div><?php echo substr($full['message'],0,100)?></div> </li> </div>
Live Demo Download Script
Great tuff, Just I dont understand Why you are doing it in this way: first you are saving the details in the database, and the fetching the same from there.
ReplyDeleteTell me one thing, why I should just take the stuff from UI itself, and show it to user as the messagebox and then save to databox. your stuffs are like AUDIO, IMG and divs are static anyways.
databox ==> database
Deleteya we can do first take data form UI and later we send to database but end of the day we should store in database... so we can go from UI to database or database to UI
DeleteIEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.
DeleteIEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.
corporate training in chennai corporate training in chennai
corporate training companies in india corporate training companies in india
corporate training companies in chennai corporate training companies in chennai
I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai
hi bro these coding can we apply in blogger
ReplyDeletethanks bro :)
ReplyDeletehttps://github.com/nalindaDJ/notiJ
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteusing this can we send notification on other users website??.. like Facebook,
ReplyDeleteActually i have code on that multiple users can make multiple tasks and other users can accept that task. at same time if any XYZ user accept my task i will get notification your task accepted by XYZ user..
Notice: Undefined variable: alert in E:\xampp\htdocs\ajax_alert\index.php on line 66
ReplyDeleteWarning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in E:\xampp\htdocs\ajax_alert\index.php on line 72
Thank you so much, you are awesome
ReplyDeleteThank you sir.
ReplyDeleteyour demo link is not working
ReplyDelete588*//*/
ReplyDelete
ReplyDeleteWell Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
web designing course in chennai
Where is .sql file?
ReplyDeleteIt is interesting to read your blog post and I am going to share it with my friends.aybabg
ReplyDeleteHi, I find reading this article a joy. It is extremely helpful and interesting and very much looking forward to reading more of your work..
ReplyDeleteMason Soiza
hello
ReplyDeletewhat is the structure of the database
I am looking for and I love to post a comment that "The content of your post is awesome" Great work!The Lion King 2019
ReplyDeleteAluminium Composite Panel or ACP Sheet is used for building exteriors, interior applications, and signage. They are durable, easy to maintain & cost-effective with different colour variants.
ReplyDeleteThank you so mutch sir for sharing good coding
ReplyDeletehttps://www.reallrishta.com/
https://www.reallrishta.com/
ReplyDeleteA very inspiring blog your article is so convincing that I never stop myself to say something about it.
ReplyDeleteWonderful post, This article have helped greatly continue writing ..
ReplyDeleteI´ve been thinking of starting a blog on this subject myself .....
ReplyDeleteA very interesting blog....
ReplyDeleteThanks for sharing information. I really appreciate it.
ReplyDeleteThanks for sharing...
ReplyDeleteVery good Keep it up.
Nice blog, it’s so knowledgeable, informative, and good looking site. I appreciate your hard work. Good job. Thank you for this wonderful sharing with us. Keep Sharing.
ReplyDeleteA very inspiring blog your article is so convincing that I never stop myself to say something about it.
ReplyDelete
ReplyDeleteA very interesting blog....
Nice blog, it’s so knowledgeable, informative, and good looking site. I appreciate your hard work. Good job. Thank you for this wonderful sharing with us. Keep Sharing.
ReplyDeleteKeep sharing the post like this...
ReplyDeleteHello Admin!
ReplyDeleteThanks for the post. It was very interesting and meaningful. I really appreciate it! Keep updating stuffs like this. If you are looking for the Advertising Agency in Chennai | Printing in Chennai , Visit Inoventic Creative Agency Today..
Thanks for sharing such a great blog
ReplyDeleteVermicompost Manufacturers | Best Vermicompost in chennai
This is such a nice useful resource that you are supplying and also you meet the price of it away for forgive. I hero reward seeing websites that take at the value of supplying a setting useful resource for set wandering. it's far the primeval what goes on the order of comes almost about recurring. Fire Place Sounds
ReplyDeleteNice blog, it’s so knowledgeable, informative, and good looking site. I appreciate your hard work. Good job. Thank you for this wonderful sharing with us. Keep Sharing.
ReplyDeleteTours and Travels in Madurai | Best tour operators in Madurai
Best travel agency in Madurai | Best Travels in Madurai
Facebook Marketing Training for your cheapest SMM panel colleagues bodes well in the event that you need to use your time as the entrepreneur.
ReplyDeleteA straightforward and viable approach to build the intrigue of your Facebook recordings just as to urge deals is to coordinate into them coupons,Facebook video downloader vouchers, and markdown codes that your crowd can't go anyplace else.
ReplyDelete
ReplyDeleteThanks for sharing such a great blog
Vermicompost manufacturers in Tamilnadu | Vermicompost in Tamilnadu
Vermicompost Manufacturers | Vermicompost Suppliers
Vermicompost in Coimbatore | Vermicompost manufacturers in Chennai
Vermicompost in chennai | Best Vermicompost in chennai
.
Twitter video downloader This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here keep up the good work
ReplyDeleteThanks for sharing such a great blog
ReplyDeleteVermicompost manufacturers in Tamilnadu | Vermicompost in Tamilnadu
Vermicompost Manufacturers | Vermicompost Suppliers
Vermicompost in Coimbatore | Vermicompost manufacturers in Chennai
Vermicompost in chennai | Best Vermicompost in chennai
Hi, Very nice article. I hope you will publish again such type of post. Thank you!
ReplyDeleteCorporate gifts ideas | Corporate gifts
Corporate gifts singapore | Corporate gifts in singapore
Promotional gifts singapore | corporate gifts supplier
Super site! I am Loving it!! Will return once more, Im taking your food likewise, Thanks. sound buttons
ReplyDeleteThanks for sharing this information. I really appreciate it.
ReplyDeleteIphone service center in tnagar | Iphone service center in chennai
Lenovo mobile service center in Tnagar | Lenovo Mobile service center in chennai
Moto service center in t nagar | Motorola service center in t nagar
Moto Service Center in Chennai | Motorola Service Center in chennai
These promotions will be highlighted in the correct hand segment of Facebook pages. speaking of
ReplyDeleteI got too much interesting stuff on your blog. I guess I am not the only one having all the enjoyment here! Keep up the good work. organic soundcloud promotion
ReplyDeleteMuch thanks for composing such an intriguing article on this point. This has truly made me think and I plan to peruse more. buy real Facebook comments,
ReplyDeleteInteresting stuff to read. Keep it up.Adidas showroom in madurai
ReplyDeleteWoodland showroom in madurai | Skechers showroom in Madurai
Puma showroom in madurai