Answered step by step
Verified Expert Solution
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 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 currprice FROM Stocks WHERE stockabbrev abbreviation;
The return value from the database is a single value representing the stock price in dollar and cents format eg 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started