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 1095859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:11:33+00:00 2026-05-17T00:11:33+00:00

How can I develop an alert system like Facebook’s, where User A add User

  • 0

How can I develop an alert system like Facebook’s, where User A add User B, User B will get some number in Friend Request Section on the header like in the image below. How can I develop something like that?
How can we get numbers like this??how can i get codes in PHP and JQuery?

alt text

  • 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-17T00:11:33+00:00Added an answer on May 17, 2026 at 12:11 am

    I presume you want a means of alerting user A, when user B ‘friends’ him/her without requiring a page refresh?

    This requires “AJAX”. AJAX stands for Asynchronous Javascript and XML, but this is an overloaded term now-a-days with the actual exchange data structure often using JSON instead of XML. JSON is JavaScript Object Notation. Anyway, the idea is that your webpage–without being refreshed–can make periodic calls to your server to get new or updated information to update the display with. With PHP and jQuery, you’ll want to first set up the AJAX call on your page like this:

    $(function() { // on document ready
    
    function updateAlerts() {
       $.ajax({
          url : "/check.php",
          type : "POST",
          data : {
             method : 'checkAlerts'
          },
          success : function(data, textStatus, XMLHttpRequest) {
             var response = $.parseJSON(data);
    
             // Update the DOM to show the new alerts!
             if (response.friendRequests > 0) {
                // update the number in the DOM and make sure it is visible...
                $('#unreadFriendRequestsNum').show().text(response.friendRequests);
             }
             else {
                // Hide the number, since there are no pending friend requests
                $('#unreadFriendRequestsNum').hide();
             }
    
             // Do something similar for unreadMessages, if required...
          }
       });
       setTimeout('updateAlerts()', 15000); // Every 15 seconds.
    }
    
    });
    

    This will, every 15 seconds, make a request to your server at the url /check.php on the same domain as the origin of the webpage. The PHP should query your database and and return the number of unread friend requests. Perhaps something like this:

    <?php
    
       function isValid(session) {
          // given the user's session object, ensure it is valid 
          // and that there's no funny business
          // TO BE IMPLEMENTED
       }
    
       function sanitize(input) {
          // return CLEAN input
          // TO BE IMPLEMENTED
       }
    
       // Be sure to check that your user's session is valid before proceeding, 
       // we don't want people checking other people's friend requests!
       if (!isValid(session)) { exit; }
    
       $method = sanitize($_POST['method']);
    
       switch ($method) {
          case 'checkAlerts' :
             // Check DB for number of unread friend requests and or unread messages
             // TO BE IMPLEMENTED
    
             $response = ['friendRequests' => $num_friend_requests,
                          'messages' => $num_unread_messages ];
    
             return json_encode( $response );
             exit;
    
          case 'someOtherMethodIfRequired' :
             // ...
             exit;
       }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i would like to know if i can develop a OpenSocial based application for
Friends, I like to know using which version of Android SDK we can develop
I was develop some Cocoa application with WebView . Now I can evaluate javascript
My idea was to develop a traffic alert system on the android platform. Basically,
How i can develop an app which will not appear in launching menu (neither
How i can develop and compile command line C++ programs in my Linux Ubuntu,
im wondering if we can develop our android app in any computer we use
How i can install the CDT plug-in (that you can develop in C++ under
Which is the best and suitable programming language that I can develop a game
I want to learn C++ so that i can develop C++ Python modules for

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.