laravel - 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);
解决方案
尝试在像这样回显您的数据之前添加报价。
name : '{{$store->name}}'
但我们无法为您提供更多帮助,没有任何错误或代码。
推荐阅读
- angular - 每日更新的网站,推荐使用 Angular 吗?
- c# - 使用连接和分组简化两个 LINQ 查询
- java - 如何修复我的 JFrame 无法打开,编译器没有给我任何错误,我该如何修复它?
- xcode - 在 Xcode 链接库中找不到 JavaScriptCore.framework
- python - 工具链没有下载工具
- javascript - 将字符串与多种模式之一匹配并提取数据
- cassandra - 作为 DSE Cassandra 5.x Java 驱动程序的一部分,是否删除了 cassandra-driver-core 依赖项?
- python - 字典到 csv 单独的列
- regex - 如何在 Notepad++ 中使用正则表达式搜索和替换以仅更改 csv 第一列中的字符
- mercurial - 等效于 'hg rebase' 的 'git rebase --skip'