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

  • Home
  • SEARCH
  • 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 6071697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:04:37+00:00 2026-05-23T10:04:37+00:00

I want to fade in new posts from my database. I have a div

  • 0

I want to fade in new posts from my database. I have a div that contains all old posts which are loaded when the page loads, and then I want new posts to fade in above the old ones.

I just got started with jQuery. I´ve tried a few things.

This code doesn’t work. (Which maybe is obvious to you.)

$('#oldMessages').html($('#oldMessages').html() + load('newPosts.php').hide().fadeIn(3000));

Thanks for your help!

  • 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-23T10:04:37+00:00Added an answer on May 23, 2026 at 10:04 am

    As the page loads (or whenever you need to load posts), try this

    $.ajax({
        url: 'newPosts.php',
        type: 'GET',
        success: function(data) {
            // assuming data is the html of your posts
            $(data).hide().prependTo($('#oldMessages')).fadeIn(3000);
            // this will fadeIn the entire response
        }
    });
    

    Edit

    This is a little hacky–the code has a couple requirements:

    1. An element (you could hide it if you wanted) with class="timePosted" with each post
    2. That is immediately followed by a tag that contains the text for elapsed time with class="timeElapsed". If you can’t do this, I think you’ll need an array with some id’s to identify each post

    Since you also need to update the elapsed times, you could try this inside your success callback function:

    $.each($('.timePosted'), function() {
        var diff = new Date() - new Date($(this).val());
    
        x = diff / 1000
        seconds = x % 60
        x /= 60
        minutes = x % 60
        x /= 60
        hours = x % 24
        x /= 24
        days = x
    
        if (days >= 1)
            $(this).next('.timeElapsed').html(days + ' days ago');
        else if (hours >= 1)
            $(this).next('.timeElapsed').html(hours + ' hours ago');
        else if (minutes >= 1)
            $(this).next('.timeElapsed').html(minutes + ' minutes ago');
        else if (seconds >= 1)
            $(this).next('.timeElapsed').html(seconds + ' seconds ago');
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page (index.php) that pulls posts from mysql database. The posts are
I have LI that I want to fade out and back in. Within the
Hi when I add a new component using Actionscript I want it to fade
I have 3 divs i want to fade in, then out and once they
Greetings to all... I want to use fade effect with jCarouselLite qualities. Is it
I have to make something like an accordion, but I want it to fade
I have a Service which is playing music. I've implemented fade out like this
Hi I'm new to JQuery. I have an two issues that I can't figure
I have a flex application and I want to add a new custom component
I want to have fade-in, fade-out effect for two image views I have two

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.