javascript - Ajax, load blade content on laravel -


i'm using gloudemans\shoppingcart laravel , trying load cart content after clicking "add cart" without page refresh ajax. able pass "cart add" data following code:

$(document).ready(function(){                    <?php $maxp = count($featured2);                    for($i=0;$i<$maxp; $i++) {?>                    $('#cartbtn<?php echo $i;?>').click(function(){                      var pro_id<?php echo $i;?> = $('#pro_id<?php echo $i;?>').val();                      $.ajax({                          type: 'get',                          url: '<?php echo url('/product/addtocart');?>/'+ pro_id<?php echo $i;?>,                          success: function(){                                //something load cart content lookig!!                          }                            });                  });                  <?php }?>              });

how can retrieve cart content in blade such as:

{{ cart::instance('main')->count() }}    //or    @foreach($cart $row)                  <li class="clearfix">                      <img src="{{$row->image}}" alt="" />                      <a href="/product_details/{{$row->id}}">{{ $row->name }}</a>                      <span>{{ $row->qty }} × $ {{ $row->price }}</span>                  </li>              @endforeach


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -