0

I use ajax to implement pagination. But I don't know how to change the Laravel pagination button href. Next page button always links to page 2.

My ajax code is below:

$('.pagination a').on('click', function (event) {
        event.preventDefault();
        if ( $(this).attr('href') != '#' ) {
            $.ajax({
                url: $(this).attr('href'),
                type: 'POST',
                data:{'_token': "{{ csrf_token() }}"},
                success: function(data) {console.log(data);
                    var data = $.parseJSON(data);
                    // 加载图书列表
                    var html = compiled_tpl.render(data);
                    document.getElementById('booklist').innerHTML = html;
                    $('.ajaxpage').html(data.render);
                }
            });
        }
    });
Tomas Ramirez Sarduy
  • 17,294
  • 8
  • 69
  • 85
guanyue
  • 445
  • 1
  • 4
  • 11
  • it shows a lot button,like prev 4 5 6 7 8 9 next ,thus there are too many to change,and i don't konw where is the start where is end – guanyue Apr 26 '15 at 02:28
  • your loaded data must also contain a page value we can not see. `var page = $(this).attr("data-page");` and your next query is based on `page` . otherwise you will always have the same page – moskito-x Apr 26 '15 at 02:56
  • ajax response data is ok, my problem is the page in the view .i use $page->vender() to generate. so it can't verify ajax,and don't know which page the real is. – guanyue Apr 26 '15 at 03:21
  • look at the response are there any variables pointing to the current page ? – moskito-x Apr 26 '15 at 03:30

0 Answers0