lundi 2 octobre 2017

How to pass and ID and call a Laravel 5.4 method in controller using JavaScript, jQuery or AJAX?

In my blade view..

<a href="#" id="plus"  onclick="incrementValue()" value="">
   <i class="material-icons"value="" id="inc" style="color:#30BB6D">add_circle</i>
   </a>

My script..

function incrementValue()
{
    var value = parseInt(document.getElementById('number').value, 10);
    value = isNaN(value) ? 0 : value;
    value++;


    document.getElementById('number').value = value;



}

What i want when this button/icon is click it will proceed to a route

Route::get('addToCart/{id}', 'HomeController@addToCart')->name('dish.addtocart');

and will also increment the quantity

Could someone help me in passing the id and calling the method in the controller?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire