我有一個大約從控制器傳遞變量的JavaScript未捕獲的語法錯誤:意外標記○在JSON位置1處
問題,這是我的控制器
public function index()
{
$tourplace = Tourism::all();
return view('spatialInfo')->with('tourplace',$tourplace);
}
這是我的javascript
$(document).ready(function(){
var lokasi = [];
var test = document.getElementsByName('kabupaten');
var jsondata = JSON.parse({!! $tourplace !!});
var htmlURL = '{{URL::to('/tourismplace/id/')}}';
$.get(jsondata).success(function(data){
var jumlahData = data.length;
for(var i=0;i<jumlahData;i++){
lokasi.push({
lat : data[i].latitude,
lon : data[i].longitude,
zoom : 15,
title : data[i].nama,
html : "<a href='"+htmlURL+"/"+data[i].id +"'>"+data[i].nama+"</a>",
icon: 'http://maps.google.com/mapfiles/ms/micons/red-dot.png', // custom icon
animation: google.maps.Animation.DROP
});
}
});
http://stackoverflow.com/questions/8081701/i-keep-getting-uncaught-syntaxerror-unexpected-token-o – vlatkokaplan