I'm receiving this error "Uncaught ReferenceError: IXIC is not defined" for my Javascript code. I've defined the global variables "httpRequest" and "entry" before the functions however only the value for "entry" is getting an error. My code below (the assignment is to fetch market information for a stock based on a stock symbol that a user specifies): "use strict"; var httpRequest = false; var entry = IXIC; function getRequestObject () { try { httpRequest = new XMLHttpRequest (); } catch (requestError) { return false; } return httpRequest;   } function stopSubmission(evt) { if (evt.preventDefault) { evt.preventDefault (); } else { evt.returnValue = false; } getQuote (); } function getQuote () { if (document.getElementsByTagName ("input")[0].value) { entry = document.getElementsByTagName ("input")[0].value; } if (!httpRequest) { httpRequest = getRequestObject(); } httpRequest.abort(); httpRequest.open ("get", "https://sandbox.iexapis.com/stable/stock/$TickerSymbol/batch?types=quote&range=1m&last=10&token=Tsk_d5ea71c8c07e42938ef76260650e269a" + entry, true); httpRequest.send(); httpRequest.onreadystatechange = displayData; } function displayData () { if (httpRequest.readyState === 4 && httpRequest.status === 200){ var stockResults = httpRequest.responseText; stockResults = httpRequest.responseText; let lenStockResults = stockResults.length; let parseString = stockResults.subString (9, lenStockResults - 1); stockItems = JSON.parse (parseString);   var ticker = stockItems.symbol; //stockItems ['symbol'] var closePrice = stockItems.close; var openPrice = stockItems.open; var avgTotalVolume = stockItems.avgTotalVolume; var nf = Intl.NumberFormat (); avgTotalVolume = nf.format (avgTotalVolume);   var weekhigh52 = stockItems.weekhigh52; var weekLow52 = stockItems.weekLow52;   document.getElementById ("ticker").innerHTML = ticker; document.getElementById ("open").innerHTML = openPrice; document.getElementById ("close").innerHTML = closePrice; document.getElementById ("52weekHigh").innerHTML = weekhigh52; document.getElementById ("52weekLow").innerHTML = weekLow52; document.getElementById ("volume").innerHTML = avgTotalVolume; } } function formatTable () { var rows = document.getElementsByTagName ("tr"); for (var i = 0; i < rows.length; i = i + 2) { rows [i].style.background = "#9FE098"; } } var form = document.getElementsByTagName ("form")[0]; if (form.addEventListener) { form.addEventListener ("submit", stopSubmission, false); window.addEventListener ("load", formatTable, false); window.addEventListener ("load", getQuote, false); } else if (form.attachevent) { form.attachevent ("onsubmit", stopSubmission); window.attachevent ("onload", formatTable); window.attachevent ("onload", getQuote); }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I'm receiving this error "Uncaught ReferenceError: IXIC is not defined" for my Javascript code. I've defined the global variables "httpRequest" and "entry" before the functions however only the value for "entry" is getting an error. My code below (the assignment is to fetch market information for a stock based on a stock symbol that a user specifies):

"use strict";

var httpRequest = false;

var entry = IXIC;

function getRequestObject () {

try {

httpRequest = new XMLHttpRequest ();

}

catch (requestError) {

return false;

}

return httpRequest;

 

}

function stopSubmission(evt) {

if (evt.preventDefault) {

evt.preventDefault ();

} else {

evt.returnValue = false;

}

getQuote ();

}

function getQuote () {

if (document.getElementsByTagName ("input")[0].value) {

entry = document.getElementsByTagName ("input")[0].value;

}

if (!httpRequest) {

httpRequest = getRequestObject();

}

httpRequest.abort();

httpRequest.open ("get", "https://sandbox.iexapis.com/stable/stock/$TickerSymbol/batch?types=quote&range=1m&last=10&token=Tsk_d5ea71c8c07e42938ef76260650e269a" + entry, true);

httpRequest.send();

httpRequest.onreadystatechange = displayData;

}

function displayData () {

if (httpRequest.readyState === 4 && httpRequest.status === 200){

var stockResults = httpRequest.responseText;

stockResults = httpRequest.responseText;

let lenStockResults = stockResults.length;

let parseString = stockResults.subString (9, lenStockResults - 1);

stockItems = JSON.parse (parseString);

 

var ticker = stockItems.symbol; //stockItems ['symbol']

var closePrice = stockItems.close;

var openPrice = stockItems.open;

var avgTotalVolume = stockItems.avgTotalVolume;

var nf = Intl.NumberFormat ();

avgTotalVolume = nf.format (avgTotalVolume);

 

var weekhigh52 = stockItems.weekhigh52;

var weekLow52 = stockItems.weekLow52;

 

document.getElementById ("ticker").innerHTML = ticker;

document.getElementById ("open").innerHTML = openPrice;

document.getElementById ("close").innerHTML = closePrice;

document.getElementById ("52weekHigh").innerHTML = weekhigh52;

document.getElementById ("52weekLow").innerHTML = weekLow52;

document.getElementById ("volume").innerHTML = avgTotalVolume;

}

}

function formatTable () {

var rows = document.getElementsByTagName ("tr");

for (var i = 0; i < rows.length; i = i + 2) {

rows [i].style.background = "#9FE098";

}

}

var form = document.getElementsByTagName ("form")[0];

if (form.addEventListener) {

form.addEventListener ("submit", stopSubmission, false);

window.addEventListener ("load", formatTable, false);

window.addEventListener ("load", getQuote, false);

} else if (form.attachevent) {

form.attachevent ("onsubmit", stopSubmission);

window.attachevent ("onload", formatTable);

window.attachevent ("onload", getQuote);

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY