1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How do I refresh page and keep a dropdown menu open

Discussion in 'JavaScript' started by ketting00, Sep 7, 2011.

  1. #1
    Hi,
    SEMrush
    I'm trying to achieve a notification feature which you see on facebook, myspace and so on.

    Here the trick that I use:
    I've pulled a number of data that a user has not been read (where active ='0') from a database to display on a notification icon on the menubar -- the exact notification icon you will see on facebook and myspace -- says 2 unread messages in bright red.

    As the user click on the notification button to open up a dropdown menu and read their unread messages I process the script and update the active = '0' to active = '1' and refresh the page.

    The problem is when the page is refreshed, the dropdown menu and the notification both disappeared.

    How do I remove only that number in red and keep the dropdown menu open, I know that both facebook and myspace didn't even refresh a page.

    In this case, I don't even know whether I use javascript or ajax. I've stolen (borrowed) the feature from twitter.

    Hope I explain what I'm trying to do clearly and thanks for your help
     
    ketting00, Sep 7, 2011 IP
    SEMrush
  2. MasterBlaster1

    MasterBlaster1 Member

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    Thank you for sharing this will come In handy.
     
    MasterBlaster1, Sep 7, 2011 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #3
    Look at the code to see which one you're using. It sounds as if you're just reloading the page. That sets the page to what it was the first time, without any of the changes you've made. You need to use AJAX to only "refresh" the elements you want changed.
     
    Rukbat, Sep 8, 2011 IP
  4. gauvion

    gauvion Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That's because facebook uses AJAX.
     
    gauvion, Sep 9, 2011 IP
  5. akumar2

    akumar2 Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ajax :) :)
     
    akumar2, Sep 20, 2011 IP
  6. developer.designer

    developer.designer Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    you must use server side language and insert that in db for that type of notification because you can't show this after page refresh with ajax.
     
    developer.designer, Oct 8, 2011 IP