您好,我正在开发一个搜索引擎网站,该网站允许您使用 Best Buy Api 查找产品,现在我无法搜索不同类别的产品。现在,我可以搜索单个类别中的项目。例如,我可以查找笔记本电脑类别中的项目,但无法查找手机类别中的项目。到目前为止,这是我的代码:
$.ajax({
type: "GET",
url: "http://api.bestbuy.com/v1/products(search=" + input + "&categoryPath.id=pcmcat209400050001)?apiKey=KEY HERE&pageSize=20&format=json&callback=?",
cache: true,
dataType: 'json',
success: function(data) {
alert('success');
console.log(data);
for(var i=0; i , data.products.length; i++) {
var result = data.products[i];
productList.append(
'<img src="'+ result.mediumImage +'"/>'
+ '<h3>'+ result.name +'</h3>'
+ '<p>'+ result.shortDescription +'</p>'
+ '<p>$'+ result.regularPrice +'</p>');
}
},
});
此示例将允许您搜索手机类别中的任何项目。我的新想法是尝试一次执行多个查询,但这仅允许您搜索最后一个 ajax 调用的产品,而不是它上面的产品。任何帮助将不胜感激。