首页 > 解决方案 > Storing data from database to javascript using Laravel

问题描述

I am new to the Laravel Framework. I tried to store data from a database to javascript using this framework. Here is my code.

var customers = [];
@foreach($data as $store)
var tobeStored = {
   id: {{$store->id}},
   name: {{$store->name}},
   contact: {{$store->contact_no}},
   latitude: {{$store->lat}},
   longtitude{{$store->lng}},
   address: {{$store->address}}
};
customers.push(tobeStored);
@endforeach
alert(customers.length);

标签: laravel

解决方案


尝试在像这样回显您的数据之前添加报价。

name : '{{$store->name}}'

但我们无法为您提供更多帮助,没有任何错误或代码。


推荐阅读