javascript - Laravel Ajax panel -
my problem when bring mouse on 2nd page button link shows in monitor down left corner this: home/?page=2 need show this: ajax/comments/?page=2. shows ajax/comments/?page=2 when press button go 2nd page , after starts work.
<div class="row content col-md-9"> <div class="panel panel-default widget"> <div class="panel-heading"> <span class="glyphicon glyphicon-comment"></span> <h3 class="panel-title"> recent comments</h3> </div> <div class="panel-body"> <ul class="list-group"> @foreach($comments $comment) <li class="list-group-item"> <div class="row"> <div class="col-xs-2 col-md-1"> <img src="{{$comment->author->image}}" alt="" /></div> <div class="col-xs-10 col-md-11"> <div> <a href="{{$comment->article->slug}}"> {{$comment->article->title}}</a> <div class="mic-info"> by: <a href="#">{{$comment->author->name}}</a> {{$comment->created_at}} </div> </div> <div class="comment-text"> {{$comment->body}} </div> </div> </div> </li> @endforeach </ul> <div class="text-center">{!! $comments->render() !!}</div> </div> </div> </div> <script> $(window).on('hashchange',function(){ page = window.location.hash.replace('#',''); getproducts(page); }); $(document).on('click','.pagination a', function(e){ e.preventdefault(); var page = $(this).attr('href').split('page=')[1]; // getproducts(page); location.hash = page; }); function getproducts(page){ $.ajax({ url: '/ajax/comments?page=' + page }).done(function(data){ $('.content').html(data); }); } </script>
i solved it! made change:
{!! str_replace('/home/?', '/ajax/comments?',$comments->render()) !!} and working
Comments
Post a Comment