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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:05:11+00:00 2026-05-21T23:05:11+00:00

The feed itself works but with the intervals on it updates itself and when

  • 0

The feed itself works but with the intervals on it updates itself and when I submit something it refreshes the page and nothing gets saved.

jQuery code:

jQuery(document).ready(function() {
    setInterval("showNewStories()", 5000);
});

function showNewStories() {
    $.getJSON("post.php", null, function(data) {
        if (data != null) {
            $("#stories").prepend($("<li><span class=\"story\">" + 
                data.story + "<br /><span class=\"date\">" + data.date + 
                "</span></li>").fadeIn("slow"));
        }
    });}

post.php:

<?php 
echo json_encode(array( "story" => $_POST['dataS'],
                                        "date" => date('l jS \of F Y h:i:s A')));
?>

What I want to know is how I can have it like Facebook’s feed where you submit something, it gets added to the feed, and then it stays there even if you refresh.

  • 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-21T23:05:12+00:00Added an answer on May 21, 2026 at 11:05 pm

    I’m not a php expert, so I can’t tell if you are already doing this, but the code on the server side should accept a parameter which will tell it what date to load the posts from.

    You should then have a variable in the javascript on the client side indicating the date/time of the latest post retrieved. When the page loads, this should be null.

    Then, the call to showNewStories would send the variable with the last datetime to the server. On the server, if the variable is passed to the php page, then it will return only the posts where the date time posted is greater than the date/time posted.

    Then, when you get the response from the server, you can add the posts to your timeline. When you add the last one, you store that date time as the date time that will be passed to the server the next time that showNewStories is called.

    There is a hole in this logic in that if the resolution of the date time on your server is not fine enough to handle the frequency of the number of posts it receives, you could run into an issue where a post is made at time x, you retrieve the list up to time x, and then another post is accepted at time x. The next time showNewStories makes a call to the server, you will miss the second post made at time x.

    To make this bullet-proof, you would change the logic on the server to include any posts where the post time is equal to the date time passed in. You would also return a unique id for each post passed back to the client.

    Then, on the client-side, when the callback to getJSON is called, you would include any items where the date time of the post is greater than the time submitted to the server or the date times are equal, and the post id returned from the server isn’t already in the list (I’d recommend including the id of the post in the list as a data attribute).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this Android code worked fine before, but i'm having problems for some reason. here
I know that I am for responsible for this in the code, but in
When reading my RSS feed with the Thunderbird feed reader, some entries are duplicated.
Slashdot's RSS feed is http://rss.slashdot.org/Slashdot/slashdot . If I download the XML file directly, I
Suppose to feed the filter standard input with these line: line 1 line 2
I have an XML feed (which I don't control) and I am trying to
How do I create an RSS feed in ASP.NET? Is there anything built in
I am receiving a 3rd party feed of which I cannot be certain of
Looking for a good rss/feed reader for windows or if there are any good
I am parsing an RSS feed from the following URL: http://rss.sciam.com/ScientificAmerican-Global?format=xml // $xml_text is

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.