let favorites = JSON.parse(localStorage.getItem('favorites'));
if (favorites !== null) {
for (let i = 0; i < favorites.length; i++) {
getFavoritesCard(favorites[i][0], favorites[i][1], favorites[i][2]);
}
} else {
$('.favorites-card').append('Здесь пусто');
}
function getFavoritesCard(id, category, subcategory) {
let data = {
'id': id,
'category': category,
'subcategory': subcategory,
};
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
url: "favorites/card",
method: 'GET',
data: data,
dataType: 'html'
});
$.ajax({
success: function (response) {
$('.favorites-card').append(response);
},
error: function(){
console.log('error');
}
});
}