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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:39:33+00:00 2026-06-05T21:39:33+00:00

I’m trying to create a pane where stocks quotes are displayed, but that automatically

  • 0

I’m trying to create a pane where stocks quotes are displayed, but that automatically refreshes every 10 seconds and that changes systematically (so have say goog for ten, then aapl and so on.)

Here’s what I got.

function stocksUpdate(latest){
 if (window.XMLHttpRequest)
 {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
 }
 else
 {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 }
 xmlhttp.onreadystatechange=function()
 {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
 {
  document.getElementById("stocks").innerHTML=xmlhttp.responseText;
 }
 }
 xmlHttp.open("GET","stock.php?latest="+latest+"&x="+Math.random(),true);
 xmlHttp.send();
 }

function stockShow() {
 var symbol = document.getElementById('stocksymbol');
 setInterval(stocksUpdate(symbol), 15);
 }
}   

then

<body onload="stockShow()">

<div id="stocks">

<h3 id="stocksymbol"></h3>

So it should first get the stocksymbol, see that its empty and get the first stock quote, then 15 seconds later get that stock quote and return the next one and so on.

The stock.php page is working perfect, but nothing is displaying. Am I initiating this correctly?? Should I make the first one show then setup the setInterval??

Note that h3 tag is deliberately empty and is accounted for in stock.php so don’t be concerned that its empty

Many thanks.
Niall

  • 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-05T21:39:34+00:00Added an answer on June 5, 2026 at 9:39 pm

    You should replace

    setInterval(stocksUpdate(symbol), 15);
    

    with

    setInterval(function(){
        stocksUpdate(symbol);
    }, 15);
    

    As of now you are evaluating the function stocksUpdate(symbol) before passing it to setInterval.

    Also, 15 is the time in milliseconds, if you don’t want your server to implode, consider raising it to something greater and maybe instead of using setInterval (that could cause 2 responses to arrive in the wrong order) use a setTimeout at the end of the stocksUpdate function

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

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.