9
I was trying to get stock quotes from yahoo api. My input to the query is only a stock ticker ( from a text field). On button click the background JavaScript method "getprice()" is called. I have a java script code that looks like this
function getprice()
{
var symbol = $('#stockquote').val();
var url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22"+symbol+"%22)%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env&format=json";
$.getJSON(url, function (json)
{
var lastquote = json.query.results.quote.LastTradePriceOnly;
$('#stock').text(lastquote);
});
}
$('#stock').text(lastquote);
Here "stock" is the text field where I want to display the LastTradePriceOnly for the given ticker.
I do not see any output turning up. Debugging also does not show up any errors. Can I get any suggestions with this issue?