获取“下一个收入日期”

时间:2015-08-08 09:46:50

标签: javascript jquery yql yahoo-finance

我每次循环运行时都尝试将“下一个收益日期”放在我的表中,问题是函数“getNED”没有返回日期,它返回“undefined”。我检查yahoo控制台中的yql查询及其确定。有人可以帮忙吗?

<script>

    /************************************************** צד ימין ********************************************************/

    //var symbol = ['MO', 'IBM', 'DIA', 'SPY', 'IWM', 'QQQ', 'AMZN', 'EBAY', 'YHOO', 'PFE', 'MU', 'ADBE', 'MYL', 'PHM', 'AAPL', 'ADSK', 'ALTR', 'AMAT', 'APOL', 'ATVI', 'BBRY', 'BIDU', 'BRCM', 'CA', 'JPM', 'BAC', 'GS', 'GOOG', 'BABA', 'CELG', 'CERN', 'CHKP', 'CHRW', 'CVX', 'CMCSA', 'CSCO', 'CTXS', 'DLTR', 'FAST', 'GMCR', 'GRMN', 'INTC', 'KLAC', 'MSFT', 'SPLS', 'XLNX', 'GILD', 'INFY', 'NFLX', 'PAYX', 'QCOM', 'SBUX'];

    var symbol = ['MO', 'IBM', 'DIA', 'SPY', 'IWM', 'QQQ'];

    $.ajax({
        url: "http://query.yahooapis.com/v1/public/yql?q=select * from csv where url='http://download.finance.yahoo.com/d/quotes.csv?s=" + symbol + "%26f=syjkl1d1t1c1ohgv%26e=.csv' and columns='symbol,Dividend_Yield,week_Low,Week_High,last_trade_price,date,time,change,col1,high,low,col2'&format=json",
        dataType: 'json',
        success: function (data) {
            $.each(data.query.results.row, function (index, item) {
                $("#header").append("<table border='1' cellpadding='0' cellspacing='0' width='500' bgcolor='yellow'><tr align='center'><td colspan='4'>" + item.symbol + "</td></tr><tr align='center'><td>Next Earnings Date</td><td>Dividend Yield</td><td>52 week Low</td><td>52 Week High</td><tr align='center'><td id='qqq'>" + getNED(item.symbol) + "</td><td>" + item.Dividend_Yield + "%</td><td>" + item.week_Low + "</td><td>" + item.Week_High + "</td></tr></table><br />");
            });
        },
        error: function () {
            $("#header").html('<p>Something has gone terribly wrong.</p>');
        }
    });

    function getNED(stockName) {
        var yql = 'select * from html where url="http://finance.yahoo.com/q?s=mo&ql=1" and xpath="//*[@id=\'table1\']//tr[7]//td"';
        var queryURL = 'https://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(yql) + '&format=json';

        $.ajax({
            url: queryURL,
            dataType: 'json',
            success: function (data) {
                return data.query.results.td.content;

            },
            error: function () {
                alert("error");
            }
        });
    }

</script>

0 个答案:

没有答案