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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:21:27+00:00 2026-06-16T21:21:27+00:00

I am trying to make a self-updating element with jQuery. Here’s my code: function

  • 0

I am trying to make a self-updating element with jQuery. Here’s my code:

function chart_readyset() {
    $.get("chart.php?live=true", function(data) {
    if(data.replace(/[ \t\r]+/g,"").split('\n').join('') != $("#chart-wrapper").html().replace(/[ \t\r]+/g,"").split('\n').join('')) {
        $("#chart-wrapper").fadeOut('fast').html(data).fadeIn('fast');
    }
    window.setTimeout(chart_readyset, 5000);
  });    
}

As you can see it loads data from chart.php?live=true and compares it to the element’s html then updates it (with flashing effect) only when data is actually updated. I had to remove all the whitespaces from html.

This code works in all browsers except IE. So I invented a new method that seems more stable and elegant. With PHP I generate some hash code and pass it through <meta> tag:

<meta id="hash" hash="25a4f466ee0b2f12fe505dd9a1151456">

So now I need to extract this data from response html. It’s pretty easy to extract it from a DOM tree:

$('#hash').attr('hash');

But I can’t do the same thing with raw html response. I tried to DOM-ify it first ($(data).find('#hash').attr('hash')) but it doesn’t work (in console log there’s just “undefined”). What am I doing wrong?

  • 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-06-16T21:21:31+00:00Added an answer on June 16, 2026 at 9:21 pm

    use this:

    $(data).filter('#hash').attr('hash');
    

    filter():

    Reduce the set of matched elements to those that match the selector or pass the function’s test.

    For More Demos and Examples :

    filter() on jQuery API

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

Sidebar

Related Questions

I'm trying to make a PHP self submitting form which inserts row into a
I'm trying to make a one to many self reference using EF4.1 code first.
I'm trying to make work a self-updating functionality in an Android widget, something simple
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
trying to make a cell which loads more, but i cant get it to
I am trying to make a self-managing partition table setup with Postgres. It all
I am trying to make my chunk of code non-thread-safe, in order to toy
I've been trying to make my classes completely self contained, but I'm having some
I'm trying to make a fork of MongoEngine that will allow auto updating of
I'm trying to make a function that checks if the user is logged in.

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.