在 Best Buy 中搜索多个类别 Api
Searching multiple categories in the Best Buy Api
您好,我正在一个搜索引擎网站上工作,该网站允许您使用 Best Buy Api 查找产品,但现在我无法在不同类别中搜索产品。现在我可以在一个类别中搜索项目。例如,我可以查找笔记本电脑类别中的项目,但无法查找单元格 phone 类别中的项目。到目前为止,这是我的代码:
$.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>');
}
},
});
此示例将允许您搜索单元格 phone 类别中的任何项目。我的 newxt 想法是尝试一次执行多个查询,但这只允许您搜索最后一个 ajax 调用的产品,而不是上面那个调用的产品。任何帮助将不胜感激。
通过将我的数据类型更改为 jsonp,我现在可以执行多个查询。
您好,我正在一个搜索引擎网站上工作,该网站允许您使用 Best Buy Api 查找产品,但现在我无法在不同类别中搜索产品。现在我可以在一个类别中搜索项目。例如,我可以查找笔记本电脑类别中的项目,但无法查找单元格 phone 类别中的项目。到目前为止,这是我的代码:
$.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>');
}
},
});
此示例将允许您搜索单元格 phone 类别中的任何项目。我的 newxt 想法是尝试一次执行多个查询,但这只允许您搜索最后一个 ajax 调用的产品,而不是上面那个调用的产品。任何帮助将不胜感激。
通过将我的数据类型更改为 jsonp,我现在可以执行多个查询。