Laravel 5 - Return 要查看的数组
Laravel 5 - Return array to view
我正在我的视图中对一些已注册的视频进行简单搜索,此搜索 return 是可通过表单上的 post 搜索的视频。
问题发生在数据的 return 中,它不会使用传递给视图的数组来更新页面。
这是我的表格:
<form action="{{ URL::to("/search-video") }}" method="POST" accept-charset="utf-8" class="formSend BuscarVideoSend" id="form-busca-video">
<div class="col l10">
<input placeholder="Searchvídeo" name="Name" type="text" class="validate input-white Name valid">
</div>
<div class="col l2">
<button type="submit" class="btnSend" > Search</button>
</div>
</form>
控制器:
public function searchVideo(Request $request){
$data = $request->all();
$videos = TbVideoModel::where(
'nm_video',
'LIKE',
'%'.$data['Name'].'%'
)->get();
return view('layouts.videos', compact('videos', $videos));
}
Html 到 return:
<section id="videoMosaic">
<div class="row ">
<ul>
@if(isset($videos))
@foreach($videos as $video)
<li>
<a class="bla-1" href="{{$video->ds_link}}">
<div class="div-imagem-texto">
<img src="http://img.youtube.com/vi/{{$video['ds_imagem_video']}}/0.jpg" alt="">
<div class="texto-sobre-imagem">
<img src="/images/play.png" alt="" class="play">
{{$video->nm_video}}
<p>{{$video->tx_video}}</p>
</div>
</div>
</a>
</li>
@endforeach
@endif
</ul>
</div>
</section>
它return在控制台 xhr 上正确地发送了数据,但是它有这个错误:
Uncaught SyntaxError: Unexpected token <
要使用搜索数据更新页面,我需要什么?谢谢
你的 compact
函数有错误:
return view('layouts.videos', compact('videos'));
我正在我的视图中对一些已注册的视频进行简单搜索,此搜索 return 是可通过表单上的 post 搜索的视频。
问题发生在数据的 return 中,它不会使用传递给视图的数组来更新页面。
这是我的表格:
<form action="{{ URL::to("/search-video") }}" method="POST" accept-charset="utf-8" class="formSend BuscarVideoSend" id="form-busca-video">
<div class="col l10">
<input placeholder="Searchvídeo" name="Name" type="text" class="validate input-white Name valid">
</div>
<div class="col l2">
<button type="submit" class="btnSend" > Search</button>
</div>
</form>
控制器:
public function searchVideo(Request $request){
$data = $request->all();
$videos = TbVideoModel::where(
'nm_video',
'LIKE',
'%'.$data['Name'].'%'
)->get();
return view('layouts.videos', compact('videos', $videos));
}
Html 到 return:
<section id="videoMosaic">
<div class="row ">
<ul>
@if(isset($videos))
@foreach($videos as $video)
<li>
<a class="bla-1" href="{{$video->ds_link}}">
<div class="div-imagem-texto">
<img src="http://img.youtube.com/vi/{{$video['ds_imagem_video']}}/0.jpg" alt="">
<div class="texto-sobre-imagem">
<img src="/images/play.png" alt="" class="play">
{{$video->nm_video}}
<p>{{$video->tx_video}}</p>
</div>
</div>
</a>
</li>
@endforeach
@endif
</ul>
</div>
</section>
它return在控制台 xhr 上正确地发送了数据,但是它有这个错误:
Uncaught SyntaxError: Unexpected token <
要使用搜索数据更新页面,我需要什么?谢谢
你的 compact
函数有错误:
return view('layouts.videos', compact('videos'));