php - Ajax in Laravel Blade -


i'm new on implementing ajax in laravel blades. i've been searching tutorials , such it's confusing. hope you'll patient me

so have blade want apply ajax refresh maybe every second.

i wonder if it's advisable apply ajax on whole page itself.

if not, here's part of blade want apply ajax (it's in forelse);

<div class="row">         @forelse($receipt_ids $receipt_id)             <div class="col-md-4">                 <div class="panel panel-default">                     <div class="panel-heading text-center">                         {{$receipt_id->receipt_id}}                     </div>                      <div class="panel-body">                         <table class="table table-bordered table-responsive">                             <thead>                                 <th>name</th>                                 <th>quantity</th>                             </thead>                              <tbody>                             @foreach($orders $order)                                 @if($receipt_id->receipt_id == $order->receipt_id)                                     <tr>                                         <td>{{$order->item}}</td>                                         <td>{{$order->qty}}</td>                                     </tr>                                 @endif                             @endforeach                             </tbody>                         </table>                     </div>                      <div class="panel-footer clearfix">                         <button type="submit" class="btn btn-success pull-right" style="margin-right: 10px;">                             <i class="fa fa-check-circle" aria-hidden="true"></i> served                         </button>                     </div>                 </div>             </div>         @empty          @endforelse     </div> 

i have feeling ajax linked time change or something.

edit: kinda have lead now. used;

<script type="text/javascript"> $(document).ready(function() {     setinterval(function()     {        alert('test');     }, 2000) }); </script> 

now problem syntax can refresh page?

your question has lot more javascript blade syntax or laravel.

laravel uses blade turn server data (list of receipts in case) in html sent browser. there, ajax (communicating server browser) done client javascript.

the current official way using laravel implement using vue.js, if have not yet suggest use jquery.

to call every second in javascript can use:

setinterval(function() {     ... }, 1000); 

inside function can use jquery's $.get retrieve results , replace contents of list. simplest way again call action returns above rendered html.

i hope gets on way.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -