I'm a newbie coder. I'm trying to insert the var cPrice in my front-end HTML page. However, it is undefined and I can't figure out why.
///////////// Display Pop-up finciton //////////////////
//Start//
$('#button1').on('click', function() {
// Show the popup
$('#openPopup').show();
// Get the symbol and name and show it in the popup
const symbolID = document.getElementById("symbolSearch").value.toUpperCase();
document.getElementById("currentSymbol").innerHTML = symbolID;
$.get("http://localhost:5000/placeOrder", function(err, price) {
console.log(price.currentPrice);
var cPrice = price.currentPrice // On the server-side it prints the correct value.
console.log(cPrice) // However, here the front-end value is undefined.
if (err) { console.log(err) } else {
document.getElementById("currPrice").innerHTML = cPrice
}
});
// Execute the function for retrieving the price
//userAction();