Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A web page has a 'stock ticker' section where users can input the stock market abbreviation for a stock and have the current price of

A web page has a 'stock ticker' section where users can input the stock market abbreviation for a stock and have the current price of that stock show on the page.
For example, the stock market abbreviation for Microsoft is MSFT; if you type "MSFT" into the text input element and press the button, the code will get the current price for Microsoft stock and display it. A timer is then used to continuously check and update the stock price.
Write the code to implement this functionality using AJAX asynchronous programming.
When the button is clicked, an interval timer is started that asynchronously gets the current price from a database every minute (60,000 miliseconds).
On the server, there is a PHP file called "get _quote.php" that queries a stock market database for current prices. The SQL statement to get the current stock price is
"SELECT curr_price FROM Stocks WHERE stock_abbrev =(abbreviation);
The return value from the database is a single value representing the stock price in dollar and cents format e.g."123.45". Use this value from the database to set the value of the element with id="stockValue".
If the stock abbreviation is spelled wrong or otherwise does not exist, the database returns zero rows. If this occurs, write "incorrect stock abbreviation" in the element for the stock value.
The file format templates are provided, fill in the code where indicated.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions