I have a search ajax that retouches some data based on what was searched, how do I play that 'date' that comes from an ajax in a foreach in php ?
$.ajax({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
type: 'get',
url: '{{route('
videos.index ')}}',
data: {
search: $valor
},
// contentType: "application/json; charset=utf-8",
datatype: "text",
beforeSend: function() {
$("#resultado").html("Carregando...");
// document.getElementById('paginate').style.display = 'none';
},
success: function(data) {
if ($.trim(data)) {
console.log(data);
$('#resultado').append(data);
$('#last_videos').html(" ");
document.getElementById('create_video').style.display = 'none';
document.getElementById('paginate_total').style.display = 'none';
document.getElementById('paginate_ajax').style.display = 'block';
} else {
$('#resultado').html("Video não encontrado no banco de dados ou URL invalida");
$('#last_videos').html(" ");
// document.getElementById('create_wistia').style.display = 'block';
}
},
error: function(data) {
$('#last_videos').html(" ");
$('#resultado').html("Erro ao pesquisar...");
}
});
I want to get the result of success ajax and play in that foreach
<div id ="last_videos">
@foreach($data as $video)
<div class="sc-box " id="{{ $video->id }}">
<div class="row">
<div class="col-md-12 text-left">
<span class="sc-code"><big>{{ $video->code_video }}</big></span>
<a href="javascript:void(0);" class="cinza"><span class="fa fa-lock"></span></a>
(<span class="fa fa-clock-o"></span> {{ $video->duration }})
<a href="{{ route('videos.edit', $video->id) }}" class="fa fa-edit"></a><br />
<b>{{ $video->title }}</b>
<br /><br />
</div>
</div>
<div class="row">
<a href="{{ route('videos.edit', $video->id) }}">
@if ($video->image)
<img style='width: 200px; height: 250px' src="{{ URL::to('/uploads/' . $video->image) }}" class="sc-class-gallery img-responsive">
@elseif ($video->thumbnail)
<img style='width: 200px; height: 250px' src="{{ $video->thumbnail }}" class="sc-class-gallery img-responsive">
@endif
</a>
</div>
</div>
@endforeach
@else
<img src="{{ URL::asset('images/no-video.png') }}" width="250">
<h3>{{ trans('field.video_index') }}</h3>
<p>{!! trans('field.text_video_index') !!}</p>
@endif
</div>