I'm facing strange problem when reading Laravel's json response. Here is my code:
$.ajax({
url: 'getallpoints',
type: 'get',
dataType: 'json',
success: function(r){
var lat = r.lat;
var lng = r.lng;
var status = r.status;
var marker = new google.maps.Marker({
position: new google.maps.LatLng(lat,lng),
map: map
});
}
});
Here is my Laravel code
In routes.php
Route::get('/getallpoints', 'PointController@getallpoints');
In PointController.php
class PointController extends BaseController {
public function getAllPoints(){
return Point::all();
}
}
I'm getting undefined for these:
var lat = r.lat;
var lng = r.lng;
I also tried Response::json(Point::all())
but the same error.