【发布时间】:2016-02-06 03:34:24
【问题描述】:
我想通过 Laravel URL 传递数据集。这是我的代码。首先,我将数据集传递给 JavaScript,然后调用 URL。
JavaScript 代码
<script type="text/javascript">
function divClick(roomState, roomCode){
// Your code here
//window.alert(roomCode); //print_output well
//value_url out put as following
//room_detail/{"id":"24","room_code":"H5016","roomState":"UnAvailable","hotelId":"5","roomTypeId":"7","created_at":"-0001-11-30 00:00:00","updated_at":"2015-11-04 06:52:09"}
//call new page
window.location.href ="{{url('room_detail/roomCode')}}";
}
</script>
routes.php 文件代码
Route::any('room_detail/{roomDetail}', function() {
return view('pages/room_details/roomMap/single_room_map_detail', compact('roomDetail'));
});
========view.blade.php================================== ======
我使用此代码打印传递值。
<section class="content">
<div class="row">
<div class="box box-warning">
<div class="gap">
<div class="box-body">
{!! $roomDetail !!}
</div><!-- /.box -->
</div><!-- /.box -->
</div><!-- /.row -->
</div>
</section><!-- /.content -->
当视图被渲染时,我得到这个错误:
Undefined variable: roomDetail
期待一些专家的帮助,通过 URL 传递这个数据集。
【问题讨论】:
标签: javascript php html laravel