0

I'm a JavaScript newbie and have no idea how to accomplish this, so a push (or shove!) in the right direction would be really great.

I have an HTML page and I need to display some data to a user that is constantly changing. The data is just text output from a web page.

What would be the best way to get the output of a page and then display that output to the user using JavaScript?

Thanks!

2
  • @mplungjan - Nice! Now I need to find a way to get the output of the web page. Commented Sep 29, 2012 at 18:27
  • var tId = setInterval(function() { location.reload(1) },10000); Commented Sep 29, 2012 at 20:43

1 Answer 1

2

If you are trying to load content from another webpage for display on your webpage I would recommend using jQuery:

$(function() {
    setInterval(function() {
        $.get('url_here', function(res) {
            $('#result').html(res);
        });
    }, 30000);
});

This will load the load entire html response into a div like <div id="result"></div> for instance, and will perform this process every 30 seconds (30000 millisconds).

If you need to only display part of the html response you'll need to parse it out of res then switch the one line to something like $('#result').html(myValue);.

If you need the server to push to the client rather than the client pulling from the server then you probably want a different solution.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.