Jump to content

Frontend: Ajax check the modified date every 5 seconds and if there are changes refresh


cb2004
 Share

Recommended Posts

Hi all.

My JS/jQuery really struggles towards the end of the week, but I was just wondering if anybody has had the need to check the modified date of a page and if there is new to refresh. If not I will take a stab at it again next week.

Have a good weekend all.

Link to comment
Share on other sites

Like a newsticker or newsfeed that updates whenever there is a new post?

I will need something of that kind in a project very soon and looked at a solution with HTMX using polling or SSE. While looking into it I stumbled across something an old thread here:

Haven't had the time to dig deeper but maybe this is good starting point for you.

Link to comment
Share on other sites

  • 3 weeks later...

I was thinking maybe it could be a bit simpler, for me all I need to do is check the modified date every 5 seconds and if it is different to what the page currently says then it just refreshes.

Link to comment
Share on other sites

3 hours ago, cb2004 said:

I was thinking maybe it could be a bit simpler

If you don't want to add a library, why not using a simple XHR? That's only a few line of JS and PHP.
On what part are you struggling exactly?

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...