You have two options (maybe more):
Use AJAX to fetch data only (preferably in JSON format), and build the markup in javascript/jquery. Since the HTML is complicated, you can use templating engines like Mustache or similar. How this works is, that you have a HTML file with common HTML stuff and something like {{symbol}} and {{number}} where you need to. Then you just pass these values to this template file using Mustache.
Fetch the entire HTML content (View with list of cards) by AJAX (not just JSON data) and paste it as the HTML to some element. You end up with code like this
jQuery
$.get('/cards', {}, function(data){
$('#container').html(data)
});
Controller
function getCards()
{
$cards = Card::all();
$data = [
'cards' => $cards
];
return View::make('cards', $data)->render();
}
and the View
@foreach ($cards as $card)
<div class="card">
{{ $card->symbol }} //or whatever
</div>
@endforeach
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community