if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
$.ajax({
type: "POST",
url: "/gethamsters",
data: {
x: position.coords.latitude,
y: position.coords.longitude
},
success: function (data) {
console.log(data);
hamsters = data;
}
});
});
}
</script>
@foreach ($hamsters as $hamster)
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="thumbnail">
<center><div>{{ HTML::image($hamster->foto, $hamster->titel, array( 'width' => 200, 'height' => 200 )) }}</div></center>
<div class="caption">
<h3><?php echo substr($hamster->titel, 0, 20); ?></h3>
<p><?php echo substr($hamster->beschrijving, 0, 50); ?></p>
<center><p><?php echo '<a href=/hamsterdetails/' . $hamster->id . ' class="btn btn-primary" role="button">Meer
info</a><br /> ';?></p></center>
</div>
</div>
</div>
@endforeach
As you can see I got data from my jquery result and I want it to pass it into the $hamsters variable in my php code. How can I do that?