JS Real-time Pop-up new message prompt box and a hint of the implementation of the audio code _javascript skills

Source: Internet
Author: User
Tags java web

In the Java Web Authentication system development, the customer requests to have the data update to be in the page pop-up prompt box, such convenient in the next staff can promptly know that has the new data submission, we can use the Ajax to realize these functions in addition to using the timely push technology.

The principle of code implementation, in the page to enable the timing of the implementation of AJAX requests, if the data is the most recent state, to perform voice prompts and pop-up box prompts, the disadvantage of this implementation is frequent call the database, the method is only suitable for the use of a small number of systems.

1, add voice prompts

<audio id= "sound" autoplay= "AutoPlay" >

Dynamically join the Playback speech file code:

document.getElementById ("Sound"). src= "<%=basepath%>admin/media/global.wav";

2, dynamic pop-up message prompt box:

Here I have imported jquery.gritter.js and jquery.gritter.css to implement the code:

JQuery (document). Ready (function () {setinterval (function () {$.post (' Ajax/linecheck ', function (data) {var json=eval ("
("+data+") "); $.each (Json,function (Index,item) {$ ("#line" +item.id). HTML ("") $.each (Item.locallist,function (index,item2) {if ( Item2.attendoclist!= "") {$ ("#line" +item.id). Append ("<li class= ' in ' id= '" "+item2.id+" ' ><div ' ") Avatar ' > "+item2.location+" </div><div class= ' message ' ><ul id=li "+item2.id+" ></ul></ Div></li> ")} $.each (Item2.attendoclist,function (INDEX,ITEM3) {if (item3.status==0) {$ (" #li "+item2.id). Append ("<li class= ' user ' ><span class= ' username ' >" +item3.person_name + "</span><br><span Style= ' color:red ' class= ' username ' > Time: "+ item3.today+" "+item3.times +" </span><br><span class= ' Username ' > Tel: "+item3.person_phone+" </span><br><span class= ' username ' > ID: "+item3.card_id+"
</span></li> 

The above content is small series to introduce the JS real-time pop-up new message box and prompted the implementation of the Code, I hope to help you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.