php - Laravel not returning controller -
php - Laravel not returning controller -
i have simple ajax() request that's supposed add together coupon if take take (via pop tag). however, when run page , click on tag , @ in console it's doing returning entire page in html. how can utilize controller specify via routes? new ajax sure that's problem is. what's supposed happen client clicks on take coupon button, ajax processes info controller , shows modal letting them know coupon has been added successfully.
a tag
<a href="#" class="btn btndefault btnsmall" id="ajaxcoupon">add coupon cart , go on shopping <i class="fa fa-arrow-right"></i></a>
ajax
$('#ajaxcoupon').click(function(e){ e.preventdefault(); $.get('ajaxaddcoupon', function(data){ $('#successcoupon').foundation('reveal', 'open'); }); }); controller & route
public function ajaxaddcoupon() { if(request::ajax()) { session::put('coupon', 'search10'); homecoming true; }; } route::get('ajaxaddcoupon', 'storecontroller@ajaxaddcoupon');
try html:
<a href="{{ url::to('ajaxaddcoupon') }}" class="btn btndefault btnsmall" id="ajaxcoupon">add coupon cart , go on shopping <i class="fa fa-arrow-right"></i></a> javascript:
$('#ajaxcoupon').click(function(e){ e.preventdefault(); var url = $(this).attr('href'); $.get(url, function(data) { $('#successcoupon').foundation('reveal', 'open'); console.log(data); // log info testing }); }); also, homecoming string instead of boolean in ajaxaddcoupon() function. hope works.
php jquery ajax laravel
Comments
Post a Comment