假設我有一個YQL查詢像這樣(其實,這是我使用的精確查詢):爲什麼我的YQL查詢在jQuery控制檯返回空值,而同一個YQL查詢在YQL控制檯返回正值?
select * from xml where url="http://blog.artbeads.com/feed/"
and itemPath="//rss/channel/item"
Run this query on the YQL Console,它應該返回10個項目。
現在考慮下面的jQuery(這幾乎是我使用的生產,除了成功的呼叫確切的代碼,但我不相信這是一個重要的因素):
// Working example at http://jsbin.com/ekomi4
$.ajax({
url: 'http://query.yahooapis.com/v1/public/yql',
dataType: 'jsonp',
data: {
q: 'select * from xml where url="http://blog.artbeads.com/feed/" and itemPath="//rss/channel/item"',
format: 'json'
},
success: function(content) { $('#content').text(JSON.stringify(content, null, ' ')) }
})
上述代碼沒有按預期執行:返回JSON對象(如預期的那樣),但是query.results
= null
(意外)。
嘗試使用curl -v或wget獲取關於請求的調試信息 – 2013-11-12 20:05:03