I have an issue that I can't solve.
In laravel I use this code to get a value from a pivot table.
@foreach($data->product as $product)
<p>{{ $product->pivot->name }}</p>
@endforeach
And i thought I could do the same with jquery, ajax but it does not work. How do I do this?
function getTable() {
$.ajax({
type: "GET",
url: "/product/table",
datatype: "json",
success: function (response) {
$('#table').html("");
$.each(response.data.product, function (key, product){
$('#table').append(
'<p>' + product.pivot.name + '</p>'
);
});
}
});
}