Bit of a noob so apology if this is an easy fix and I'm just an idiot..
So I'm trying to get this function to work on my wordpress site..
^ It's a simple function that hits the Yahoo YQL DB and pulls a stock quote and presents it.
I've registered and and enqueued the JS with wordpress like this:
wp_register_script( 'stockcatch', get_template_directory_uri() . '/js/stockcatch.js', array( 'jquery' ), '1.1', 'true' );
wp_enqueue_script( 'stockcatch' );
and then added this code into my wordpress page in the text section:
<input type="text" value="CSCO" id="stockquote" />
<div id="stock"></div>
<button onclick="getprice();">Get price</button>
<script type='text/javascript' src='http://stockology.ws/wp-content/themes/willow/js/stockcatch.js?ver=1.1'></script>
but when I click the get quote button, nothing happens. I also tried adding the entire function within the for the JS but nothing..
What's the issue?
EDIT: here is the JavaScript I've added to WP..
/*
Catch stock quote from Yahoo! YQL
*/
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);
});
}