Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6746291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:18:19+00:00 2026-05-26T12:18:19+00:00

Sorry if I didn’t show you the whole code, because I am not sure

  • 0

Sorry if I didn’t show you the whole code, because I am not sure how to implement it. I looked at facebook message notification box, if any new recent messages coming, on the top right of the message icon, a red number will be located there and overlay the message box, and when you click the number, it just disappear and the new messages are shown to you, I want to know how to implement that, and when more new messages coming the number indicating how many messages will appear again, did they use ajax auto refresh div to achieve that? So suppose I have the following message box:

     <style>
    #messsge{width:100px;height:50px;border: 1px soild #000000;}
    #number{color:#ff0000;position:abosolute; z-index:999;top:-40px;left:-90px;}
    </style>
    <a href="#"><div id="message"></div></a><span id="number">3</span>
  <script>
   $("#message").click(function (e) { 
     e.preventDefault();
     $("#number").hide();
        });
     var auto_refresh = setInterval(function (){
  $('#number').load('number.php').fadeIn("slow");
   }, 1000);//not exactly sure how to refresh the number, I assume probably don't need to retrieve it from another php file.


  </script>

I am not sure if I did the right thing, could any body help me with that, thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:18:19+00:00Added an answer on May 26, 2026 at 12:18 pm

    you may try something like

    in your number.php

    //get the userid or some id from which you can specify the user from which the request is coming 
    //e.g. $id=$_SESSION['CurrentUserID']
    //apply some logic to determine if the user has new messages if he has some new msgs
    $hasNewMsg="yes";
    //calculate the number of messages 
    $newMsgs=5;
    echo json_encode(new array("hasMsg"=>$hasNewMsg,"newMsgs"=>$newMsgs));
    
    //and if no new msgs
    echo json_encode(new array("hasMsg"=>"no"));
    

    on the client side

    <style>
        #messsge{width:100px;height:50px;border: 1px soild #000000;}
        #number{color:#ff0000;position:abosolute; z-index:999;top:-40px;left:-90px;}
        </style>
        <a href="#"><div id="message"></div></a><span id="number">3</span>
    

    javascript/jquery

    $(function(){
    $("#message").click(function (e) { 
         e.preventDefault();
         $("#number").hide();
            });
    
    var auto_refresh = setInterval(function (){
    
    $.ajax({
    type:"POST",
    dataType:"json",
    success:function(data){
    if(data.hasMsg=="yes"){
    $("#number").text(data.newMsgs).fadeIn('slow');
    }
    else//do nothing    
    },
    error:function(jxhr){
    console.log(jxhr.responseText);
    }   
    });    
    });    
    });
    

    Desclaimer: i am not familiar with php so …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update Sorry. I didn't mean the whole reflection library was off limits. I just
Sorry to repeat old questions, but I didn't quite understand the answer. The question
Sorry if this question is answered already, but I didn't find a suitable answer.
Sorry for this not being a real question, but Sometime back i remember seeing
Sorry, I'm new to SVN and I looked around a little for this. How
Sorry for the second newbie question, I'm a developer not a sysadmin so this
I'm sorry if I didn't explain my problem well enough in the title. In
[ Update: Changed question title to be more specific] Sorry if I didn't make
I am sorry I didn't know how to title my question any better, you
Sorry i really didn't know how to phrase the question any better but here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.