我如何避免追加重复
**` return Product::owned()->where("label", "{$name}")
->skip(1)->take(5)->get()->all();`**
我的jquery在
之下$(".search_product").keyup(function () {
var name = $(this).val();
$(".product_lists").empty()
$.ajax({
url : "{{\CLEM\Helper::route('sale_pos_getProductDataByName')}}",
type: "post",
data : {
_token: "{{csrf_token()}}",
name: name,
},
success: function(data){
console.log(data);
var html = '';
for( var i = 0 ; i < data.stock.length ; i++)
{
$(".product_lists").empty()
html += ('<div class="col-xs-2">' +
' <button title="'+data.stock[i].label+'" id="'+data.stock[i].code+'" value="'+data.stock[i].code+'" type="button" class="img-thumbnail btn-default product add_pro_menu pos-tip" data-container="body"> ' +
'<table>' +
' <tr> <td>'+data.stock[i].label+'</td> ' +
'</tr> <tr> <td> <img src="{{Helper::assetUrl('/uploads').'/'}}'+data.stock[i].image_url+'" alt="" style="width:60px;height:60px; text-align: center" class="img-circle img-responsive img-thumbnail"/> </td> </tr> <tr> <td>Qty: '+data.stock[i].quantity+'</td> </tr> <tr> <td> Price: {{\CLEM\Helper::getDefaultCurrency()}}'+data.stock[i].price+'</td> ' +
'</tr> </table>' +
' </button> ' +
'</div>')
}
$(".product_lists").prepend(html)
}
});
});
即我希望列表上有5个项目,但我在列表中得到10个项目我不知道问题是什么。任何帮助将不胜感激