在ebay api中显示价格

时间:2014-03-17 17:36:15

标签: javascript json ebay

我试过这段代码显示ebay搜索结果其他一切正常但价格显示未定义, 请帮忙..

// Parse the response and build an HTML table to display search results
function _cb_findItemsByKeywords(root) {
var items = root.findItemsByKeywordsResponse[0].searchResult[0].item || [];
var html = [];
html.push('<table width="100%" border="0" cellspacing="0" cellpadding="3"><tbody>');
for (var i = 0; i < items.length; ++i) {
var item     = items[i];
var title    = item.title;
var pic      = item.galleryURL;
var viewitem = item.viewItemURL;
var selling  = item.currentPrice;
if (null != title && null != viewitem) {
  html.push('<tr><td>' + '<img src="' + pic + '" border="0">' + '</td>' + 
  '<td><a href="' + viewitem + '" target="_blank">' + title + '</a></td>' + '<td>' +      selling + '</td></tr>');
}
}

1 个答案:

答案 0 :(得分:2)

var selling  = item.sellingStatus[0].currentPrice[0]['__value__']

卖出参数深入到物品对象内部,如上所示