您好我们网站的某些部分只是继续加载,当我尝试通过Inspect元素检查时,我有一个错误未捕获的SyntaxError:意外的令牌; 并根据检查我有这个代码的问题
<script>
<?php echo "var place =".$city.";"; ?>
jQuery(document).ready(function(){
//console.log(place);
getLocation();
//get_locations(place.city,'<?php echo BASE_URL.'clinics/get_near_locations'; ?>');
});
function getLocationByCity(data){
var city = place.city;
var url = '<?php echo BASE_URL.'clinics/get_near_locations'; ?>';
// if(city!='false')
// jQuery('#current-city').html('Current City: '+city);
jQuery.ajax({
url:url,
type: 'POST',
dataType: 'html',
data:'city='+city,
beforeSend: function(){
jQuery('.button').html('<span>Please wait...</span>');
},
success: function(data){
jQuery('#clinic-locations').html(data);
}
});
}
function getLocation()
{
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(getLocationByLatLong,errorHandler,{timeout:6000});
}else{
getLocationByCity();
}
}
function errorHandler(err)
{
console.log(err);
console.log('errorHandler');
getLocationByCity();
}
function getLocationByLatLong(position)
{
jQuery.ajax({
url:'<?php echo BASE_URL.'clinics/get_near_locations'; ?>',
type: 'POST',
dataType: 'html',
data:'latitude='+position.coords.latitude+'&longitude='+ position.coords.longitude,
beforeSend: function(){
jQuery('.button').html('<span>Please wait...</span>');
},
success: function(data){
jQuery('#clinic-locations').html(data);
}
});
}
我也尝试从第二行删除; 但没有运气。 有人可以帮忙吗?谢谢!
答案 0 :(得分:1)
您的问题出在第一行:
public function getIndex()
{
$stoves = Stove::all();
return view('stoves.index');
}
public function anyData()
{
$stoves = Stove::select(['id','stoveno', 'refno', 'manufactuerdate', 'created_at']);
return Datatables::of($stoves)
->addColumn('action', function ($stoves) {
return '<a href="stove/show/'.$stoves->stoveno.'" class="btn btn-invert"><i class="glyphicon glyphicon-edit"></i> History</a>';
})
->make(true);
}
public function addData()
{
//
return view('stoves.new');
}
public function store(AddStove $request)
{
Stove::create($request->all());
return redirect('stove');
}
public function getShow($id)
{
$stove = Stove::findorFail('$id');
return view('stoves.view', compact('stove'));
}
public function edit($id)
{
//
}
public function update(Request $request, $id)
{
//
}
public function destroy($id)
{
//
}
字符串应该在引号或撇号附近,因此将其更改为
Route::controller('stove', 'StoveController', [
'anyData' => 'stove.data',
'getShow' => 'stove.show',
'getIndex' => 'stove',
]);
Route::get('newstove', 'StoveController@addData');
Route::post('newstove', 'StoveController@store');