I'm trying to fetch data live from database using javascript and Laravel, but I'm getting an error "syntax error, unexpected '<'"
in blade file. I was following this and now I'm stuck. How can I fetch live data from database?
Blade View
<span id="mycount">
@if( > 0)
<h1>Hello/h1>
@else
@endif
</span>
jQuery
$.ajax({
type: "GET",
url: "",
success: function(data) {
$('#mycount').html(data);
setTimeout(getCount, 1000);
}
});
Controller
public function getCount(){
{
echo ProductReview::where('product_id',$this->id)->avg('rating');
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire