Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
