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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:29:45+00:00 2026-05-12T11:29:45+00:00

I am working on a AJAX/jquery notification script. Currently it retunrs a whole fhtml

  • 0

I am working on a AJAX/jquery notification script.
Currently it retunrs a whole fhtml formatted page every 10 seconds in the AJAX response.
The page it is returning is a PHP page which only shows items that should be shown
(only items that have something NEW show up, like a new mail message or a new comment etc..)

I am wanting to change this to use JSON instead though so on my main page (parent) I will have DIV’s for each notification item and by default they will be hidden using CSS
and the JSON response will tell which items I should un-hide.

So that is my basic plan and below is some mockup code for visual.

the JSON response, out of like 10 possible items, it will only return the items marked with a 1 (meaning yes to show that item)
The 1 might not even be required since I am only showing items which are already confirmed to be showed with PHP?

{"mail":"1", "friend_request":"1" , "comment":"1" , "photo_comment":"1"},

On the main parent page there will be DIV’s with CSS to make them hidden like this. (only 4 items for the demo)

<style type="text/css">
#mail_notification{
    display: none;
}
#friend_request_notification{
    display: none;
}
#comment_notification{
    display: none;
}
#photo_comment_notification{
    display: none;
}
</style>

<div id="mail_notification"><a href="someurl.com/mail.php?id2424">New Mail</a></div>
<div id="friend_request_notification"><a href="someurl.com/mail.php?id2424">New Friend Request</a></div>
<div id="comment_notification"><a href="someurl.com/mail.php?id2424">New Profile COmments</a></div>
<div id="photo_comment_notification"><a href="someurl.com/mail.php?id2424">New Photo Comments</a></div>

So can someone show me how I would do this?


Here is my CUREENT code for showing the ajax notification, using the OLD method, it does not use JSON yet

<!-- Auto update/look for NEW notifications -->
<script type='text/javascript'> 
$(document).ready(function(){ 
     var updatenotification = function(){ 
          $('#notificationcontainer') 
               .load('/modules/member/home/notifications.inc.php') 
               .fadeIn("slow"); 
     }; 
     var auto_refresh = setInterval(function(){updatenotification();}, 5000); 
     updatenotification(); 
}); 
</script>
<!-- ENDS HERE -->
  • 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-12T11:29:46+00:00Added an answer on May 12, 2026 at 11:29 am

    Change your update notification message to use get instead of load and have the callback iterate through the JSON keys, showing those DIVs for which the value corresponding to the key is a 1.

    var updatenotification = function() {
      $('#notificationcontainer')
        .get('/modules/member/home/notifications.inc.php', null, function(data) {
          for (key in data) {
            if (data[key]) {
              $('#' + key + '_notification').fadeIn();
            }
          }
        });
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is the complete code of the jquery AJAX tab script I am working
I'm trying to get a tracking script working that uses AJAX via JQuery. This
I'm working from VS10 and have a master page that loads jQuery via: <script
Im working on a project currently and really using javascript, Jquery / AJAX heavily
I'm working on a project that makes heavy use of jQuery tabs and Ajax.
I am working on ajax-page using PageMethods (web service) to interact with server. I
I am currently working on some Ajax heavy code and I am wondering how
Ajax Jquery form not working vs div why its happen and how can i
I am very new to javascript and ajax/jquery and have been working on trying
Currently my AJAX is working like this: index.php <a href='one.php' class='ajax'>One</a> <div id=workspace>workspace</div> one.php

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.