+ Reply to Thread
Results 1 to 5 of 5
Like Tree2Likes
  • 2 Post By espfutbol98

Thread: How do Facebook Notifications Work?

  1. #1
    espfutbol98's Avatar
    espfutbol98 is offline x10 Sophmore espfutbol98 is an unknown quantity at this point
    Join Date
    Apr 2009
    Location
    Zagreb... želim
    Posts
    200

    Question How do Facebook Notifications Work?

    I have been wondering for a while how the notifications on Facebook work, most noteably the bubble on the bottom left that says something like ".... commented on your photo" and the number balloon by the messages drop-down menu. I know AJAX is involved along with PHP and a database engine such as MySQL but I'm not sure exactly how it works. I someone could show the method, I'm sure I can figure out the rest. Thanks!
    dinomirt96 and karimirt47 like this.

  2. #2
    RicardoCabral is offline x10Hosting Member RicardoCabral is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    18

    Re: How do Facebook Notifications Work?

    There are many ways to do that and I don't know which one facebook chose.

    But the first idea that comes to my mind is having a table with the notifications and field one of the fields can be a boolean that changes the value when the user reads the notification. As facebook store the last notifications, when a new notification is inserted, the oldest is removed (if it was already read).

    The changes on the interface are made by AJAX. facebook uses jQuery? I don't know. But it could be done easily with jQuery to handle the AJAX process. I know that the response is returned using JSON.

    Just a side note. If you find out how exactly facebook does it (or anything else), I advise you to do the opposite. facebook is the second most visited in the web, but it does not mean it has good programmers.
    Last edited by RicardoCabral; 06-19-2010 at 01:54 PM.

  3. #3
    callumacrae's Avatar
    callumacrae is offline not alex mac callumacrae is just really nice
    Join Date
    Dec 2007
    Location
    Wellesbourne, England
    Posts
    5,162

    Re: How do Facebook Notifications Work?

    Facebook uses a LOT of AJAX. I remember my school unbanned it for a bit, but it crippled the server.

    ~Callum
    I can customise your phpBB board. Send me a PM.
    lynxphp - info, tutorials and scripts
    "A forum post should be like a skirt; long enough to cover the subject but short enough to keep things interesting."

  4. #4
    smithee's Avatar
    smithee is offline x10Hosting Member smithee is an unknown quantity at this point
    Join Date
    Aug 2009
    Location
    NIMBY
    Posts
    45

    Re: How do Facebook Notifications Work?

    Following on from what Alex has said, here's only a few features on Facebook where chances are it uses Ajax:
    • The three icons at the top-left to alert you of any new friend requests, private messages, or notifications
    • The search box
    • The news feed (regularly updates itself)
    • Recommended pages (when you like/dismiss one, it'll show another)
    • Shows which friends are online
    • Facebook chat itself
    • The news feed again when you scroll to the bottom

    And the list above only shows the ones that are fully automated on the Home page!! These will be fetched regularly from a database by using a JavaScript timer. I'm not even going to mention the ones where you click to activate an Ajax script, simply because there's far too many! If you click on a link anywhere on Facebook, 98% of the time it will run an Ajax script one way or another. Notice that when you go to another page, the http address doesn't really change, but only the end part after a hash (#), pretty much like for a bookmark anchor... yep, you guessed it, the entire clean-up of a page and loading a new one is done through Ajax as well! That's why the top and bottom bar stays where they are; even after what seems to be like going to a new page as it shows completely different content, you are still in fact on the same page.
    .

    Be nice to nerds. Chances are you’ll end up working for one. - Bill Gates

  5. #5
    espfutbol98's Avatar
    espfutbol98 is offline x10 Sophmore espfutbol98 is an unknown quantity at this point
    Join Date
    Apr 2009
    Location
    Zagreb... želim
    Posts
    200

    Re: How do Facebook Notifications Work?

    Alright guys, thanks. This should help me get started a little easier.

+ Reply to Thread

Similar Threads

  1. Email notifications not received
    By amruthls in forum Free Hosting
    Replies: 2
    Last Post: 05-27-2010, 11:53 AM
  2. Trouble opening notifications
    By swolf387 in forum Free Hosting
    Replies: 3
    Last Post: 03-07-2010, 10:27 AM
  3. X10 Hosting Notifications
    By ajayesh in forum Feedback and Suggestions
    Replies: 7
    Last Post: 02-06-2010, 11:05 PM
  4. Forums that work with Facebook Connect
    By Jeremia0 in forum Scripts & 3rd Party Apps
    Replies: 0
    Last Post: 01-23-2009, 02:34 PM
  5. Problem in forum with notifications
    By melp57 in forum Feedback and Suggestions
    Replies: 1
    Last Post: 09-16-2007, 11:58 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers