2010-12-07 12 views
2

Yahooからのこのフィード(YQL)があり、ウェブページに情報を出力する必要があります。誰か助けてください。ありがとう!!これは私に深刻な頭痛を引き起こしています。jQueryの読み込みと出力JSONデータ

cbfunc({ 
"query": { 
    "count": "1", 
    "created": "2010-12-07T10:38:18Z", 
    "lang": "en-US", 
    "results": { 
    "quote": { 
    "symbol": "^FTSE", 
    "Ask": null, 
    "AverageDailyVolume": "0", 
    "Bid": null, 
    "AskRealtime": null, 
    "BidRealtime": null, 
    "BookValue": null, 
    "Change_PercentChange": "+67.33 - +1.17%", 
    "Change": "+67.33", 
    "Commission": null, 
    "ChangeRealtime": "+67.33", 
    "AfterHoursChangeRealtime": "N/A - N/A", 
    "DividendShare": null, 
    "LastTradeDate": "12/7/2010", 
    "TradeDate": null, 
    "EarningsShare": null, 
    "ErrorIndicationreturnedforsymbolchangedinvalid": "N/A", 
    "EPSEstimateCurrentYear": null, 
    "EPSEstimateNextYear": null, 
    "EPSEstimateNextQuarter": null, 
    "DaysLow": "5769.67", 
    "DaysHigh": "5838.52", 
    "YearLow": "4790.04", 
    "YearHigh": "5902.11", 
    "HoldingsGainPercent": "- - -", 
    "AnnualizedGain": "-", 
    "HoldingsGain": null, 
    "HoldingsGainPercentRealtime": "- - -", 
    "HoldingsGainRealtime": null, 
    "MoreInfo": "cnv", 
    "OrderBookRealtime": "N/A", 
    "MarketCapitalization": null, 
    "MarketCapRealtime": null, 
    "EBITDA": null, 
    "ChangeFromYearLow": null, 
    "PercentChangeFromYearLow": null, 
    "LastTradeRealtimeWithTime": "5:20am - <b>5837.61</b>", 
    "ChangePercentRealtime": "+67.33 - +1.17%", 
    "ChangeFromYearHigh": null, 
    "PercebtChangeFromYearHigh": null, 
    "LastTradeWithTime": "5:20am - <b>5837.61</b>", 
    "LastTradePriceOnly": "5837.61", 
    "HighLimit": null, 
    "LowLimit": null, 
    "DaysRange": "5769.67 - 5838.52", 
    "DaysRangeRealtime": "5769.67 - 5838.52", 
    "FiftydayMovingAverage": null, 
    "TwoHundreddayMovingAverage": null, 
    "ChangeFromTwoHundreddayMovingAverage": null, 
    "PercentChangeFromTwoHundreddayMovingAverage": null, 
    "ChangeFromFiftydayMovingAverage": null, 
    "PercentChangeFromFiftydayMovingAverage": null, 
    "Name": "FTSE 100", 
    "Notes": "-", 
    "Open": "5770.28", 
    "PreviousClose": "5770.28", 
    "PricePaid": null, 
    "ChangeinPercent": "+1.17%", 
    "PriceSales": null, 
    "PriceBook": null, 
    "ExDividendDate": "N/A", 
    "PERatio": null, 
    "DividendPayDate": "N/A", 
    "PERatioRealtime": null, 
    "PEGRatio": null, 
    "PriceEPSEstimateCurrentYear": null, 
    "PriceEPSEstimateNextYear": null, 
    "Symbol": "^FTSE", 
    "SharesOwned": null, 
    "ShortRatio": null, 
    "LastTradeTime": "5:20am", 
    "TickerTrend": "N/A", 
    "OneyrTargetPrice": null, 
    "Volume": "0", 
    "HoldingsValue": null, 
    "HoldingsValueRealtime": null, 
    "YearRange": "4790.04 - 5902.11", 
    "DaysValueChange": "- - +1.17%", 
    "DaysValueChangeRealtime": "- - +1.17%", 
    "StockExchange": "FSI", 
    "DividendYield": null, 
    "PercentChange": "+1.17%" 
    } 
    } 
} 
}); 
+0

あなたのQはなんですか?これはあなたを助けるかもしれないhttp://lanitdev.wordpress.com/2010/02/26/using-jquery-and-yql-to-get-an-rss-feed-from-a-site/ – benhowdle89

+0

何が好きだろう出力?より具体的になり、plsをしたいことを明確にすることができますか? – AnarchistGeek

答えて

1

ヘッド破壊の2日後に回答を得ました。信じられないここにコードがあります。それは、FTSE 100のYQLクエリからデータを出力することだけでした。みんなに答えてくれてありがとう!

<div id="finance"></div> 

<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script> 
<script type="text/javascript"> 
$(function() { 
    $.getJSON(

"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22%5EFTSE%22)%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=?", 

function(json){ 
    $('#finance').text(json.query.results.quote.Change); 
    // Patching payload into page element ID = "dog" 
}); 


}); 
</script> 
0

jQuery.getJSON()笑:GETのHTTPリクエストを使用してサーバからのJSONエンコードされたデータをロードします。

jQuery.parseJSON:正常なJSON文字列を受け取り、結果のJavaScriptオブジェクトを返します。

0

正確に何を出力しようとしていますか?これは、文字列形式の有効なJSONオブジェクトである場合は、JSONは、あなたがヤフーから受けているフィードです...

var obj = eval(JSON); 

を使用することができます。

オブジェクトのプロパティにアクセスすることができます。

var queryCount = obj.query.count;