mardi 25 avril 2017

Laravel, get data from controller for display purposes

I'd like to display data calculated in controller in blade view based on data provided in form . For now I'm doing this by:

//View xyz.blade.php
<div class="card">
    <div class="card-header">Add link</div>
    <div class="card-block">
        
        
        <div class="form-group">
            
            
        </div>
        
        
    </div>

    @if( ! empty($similar))
        This url was found in the following FREDs:<br/>
        <div class="card-block">
            @foreach ($similar as $item)
                 <br/>
            @endforeach
        </div>
    @endif
</div>

//Controller
public function getSimilar(){
    ..
    return View('xyz', ['similar' => $found]);
} 

The above code works as expected. I can provide a url and after clicking "Get" I can see a list of found items below the form. However, something tells me that this is not the right way to do this since the entire page will refresh. Am I right (and so the above code is bad)? If so, is there any build in feature to display fetched data without refreshing?




Aucun commentaire:

Enregistrer un commentaire