0

YQL query to pick up share price from Yahoo Finance is flagging up 'Uncaught TypeError: Cannot read property 'quote' of null'

Hello! I need urgent help please. We got this code from a client's old site and since the new live site their share code has changed. I changed the share code in the HTML but it seems to be flagging up the above error and not pulling in the share price anymore. Any help greatly appreciated.

Thanks,

Deb

by
1 Reply
  • Oops the code has rendered here it is again:

    <script>
    
        $(document).ready(function() {
            var $ticker = $('#ticker');
            if ($ticker.length == 1) {
    
                var tickerStatement = 'select '+$ticker.attr('data-pricefield')+', Change from yahoo.finance.quotes where symbol in ("'+$ticker.attr('data-symbol')+'")';
    
                var yqlQuery = $.ajax({
                    url: "<http://query.yahooapis.com/v1/public/yql>",
                    dataType: "jsonp",
                    data: {
                        q: tickerStatement,
                        format: "json",
                        env: '<store://datatables.org/alltableswithkeys>'
                    //    callback: "?"
                    }
                });
    
                yqlQuery.success(function(response) {
                    var quote = response.query.results.quote;
    
                    var changeDirection = 'change-none';
                    if (quote.Change > 0) {
                        changeDirection = 'change-increase';
                    } else if (quote.Change < 0) {
                        changeDirection = 'change-decrease';
                    } else {
                        quote.Change = '&mdash; &nbsp;No change';
                    }
    
                    $('#ticker-price').html(quote[$ticker.attr('data-pricefield')]);
                    $('#ticker-change').html(quote.Change).addClass(changeDirection);
                    $('#ticker').removeClass('hidden');            
                });
            }
    
        });
    
    </script>
    
    <div id="ticker-outer">
            <a href="<http://www.asx.com.au/asx/research/companyInfo.do?by=asxCode&amp;asxCode=SPZ>" target="_blank" class="png" id="ticker" data-symbol="SPZ.AX" data-pricefield="PreviousClose">
                <span id="ticker-top-text">SPZ: <strong>$AU</strong></span>
                <strong><span id="ticker-price"></span></strong>
                <span id="ticker-change" class="change-none"></span>
                <span id="ticker-change-checked">as of last close</span>
            </a>
           </div>
    
    0

Recent Posts

in YQL