May be you don't understand my requirement .I have worked before with ajax but that was so simple .Just pagination with ajax but right now I need ajax pagination in my Laravel project with category and sub category .Tell me once more please ...so I can do that as well. How can I fetch category and sub category id on url through ajax request. Here is my route ..
Route for shop page :
Route::get('/shop/{category}/{subCategory?}', 'FrontendController@productCategory')->name('frontend.shop');
Route For Ajax Request:
Route::get('/shop-paginate', 'FrontendController@shopPaginate')->name('shop_paginate');
Ajax Code :
$(document).ready(function(){
$(document).on('click','.pagination a', function(event){
event.preventDefault();
var myUrl = $(this).attr('href');
var page = $(this).attr('href').split('page=')[1];
$('li').removeClass('active');
$(this).parent('li').addClass('active');
shopPaginate(page);
});
function shopPaginate(page){
$.ajax({
type:"get",
url: "{!! route('shop_paginate')!!}?page="+page,
cache: false,
success:function(data){
$('#rangediv').html(data);
location.hash = page;
}
});
}
});