Question

I tried this code to display eBay search result everything else is working fine except that price is showing as undefined.

// 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>');
}
}
Was it helpful?

Solution

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

The selling paramter comes deep inside the item object as shown above

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top