Hi all, can any one please clear my doubts regarding the Laravel Ajax Pagination,
Here is my Controller, The query is
$products_query = Product::with('product_images')->where('parent_category_id', '=', $category->id)->where('enabled', '=', '1')->orderBy('product_position');
$products = $products_query->paginate(Input::get('pagination'));
Here is my View code which get the Pagination links from $products Query
<div class="page-setup">
{{$products->links()}}
</div>
So i need to get the $products->links() values to pass Ajax, because i lost my Pagination data once posting the call ajax, so i need to fetch the values and pass it to Ajax request
Here is My Ajax Code:
$(function () {
/*$('.filterable').on('change', function(e) {
vals = {};
vals[this.id] = $('#'+this.id).val();
ajax_filter(vals);
});*/
$('form[name="search1"]').submit(function(e) {
maxpr = $('#maxprice').val();
minpr = $('#minprice').val();
paginator = $('#paginator').val();
change_prods = $('#change_products').val();
vals = {minprice: minpr, maxprice: maxpr,pagination: paginator,orderby: change_prods};
vals[this.id] = $('#'+this.id).val();
vals['attribute_value_id'] = $('.attribute_values:checked').map(function(i,n) {
return $(n).val();
}).get(); //get converts it to an array
ajax_filter(vals);
e.preventDefault();
});
})
// common function for ajax call. Extend this to pass new variables
var ajax_filter = function(filldata) {
var slug = '{{$available_price_range["slug"] or ''}}';
var fdata = {
ajax: 1,
minprice: 0,
maxprice: '',
search_keyword: $('#search_keyword').val(),
attribute_value_id : ''
}
var data = $.extend({}, fdata, filldata);
//console.log(data)
$.ajax({
url: '{{URL::to('/')}}/category/'+slug,
type: 'post',
data: data,
success: function(resp) {
$('.fabric_thumb1').html(resp);
}
})
}
So any one please help me to fix the issues here.Thanks in Advance
Thanks alot @jimgwhit for your reply, But i need to pass the $products->links() record it's enough so any possibilities to get that, for example above i have posted the Ajax code there is
success: function(resp) {
$('.fabric_thumb1').html(resp);
}
It's seems the result as print the HTML Data of fabric_thumb1 class in that class the pagination HTML data also coming so i need to get that alone, so please check with that it's enough.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community