Problem with multiple pagination on same page with LARAVEL and AJAX?

I'm trying to enable 2 paginations from 2 different models on same page.But with AJAX only one pagination work properly, calling AJAX technology to second Laravel Pagination create a infinite loop. Both pagination are located in same class success_login from where implemeted ajax call. I know there is a lot of code but i spent half day in solving this problem and i was not able to solve it. Result of multiple ajax laravel pagination

Result of multiple ajax laravel pagination enter image description here

Controller

function successlogin(Request $request) {

      $posts= Post::orderby('created_at', 'desc')->paginate(3, ['*'], 'page_1s'); 
       if ($request->ajax()) {

            return view('presult',  compact('posts'));

        }



 $documents= Document::orderby('created_at', 'desc')->paginate(2, ['*'], 'page_2s');    
        if ($request->ajax()) {

            return view('table',  compact('documents'));

        }

     return view('main_page', ['posts'=>$posts,'documents'=>$documents]);

    }

Preresult_blade

    {{-- listing the contents on the page  --}}
         @if (count($posts) > 0)

                        <div class="camp">
                      @foreach ($posts->chunk(3) as $items)
                            <div class="row">  
                                @foreach ($items as $post)

                              <div class="col-md-4">
                    <div class="card-content">

                        <div class="card-img">
                        @if( $post->post_thumbnail )  
                        <img src="/uploads/{{ $post->post_thumbnail }}" alt="{{ $post->post_title }}" />
                            @else
                              <img src="/uploads/no-image.png" alt="" />
                         @endif



                        </div>
                        <div class="card-desc">
                            <h3><a href="/posts/{{$post-> id}}">{{$post->title}}</a> <br> <h6 style="text-align: center;">{{$post->created_at->toFormattedDateString()}}</h6></h3>

                            <p>

                                {{ str_limit($post->content, $limit = 75, $end = '...') }}</p>

             <a href="/posts/{{$post-> id}}" class="btn btn-hot text-capitalize btn-xs" style=" width:100px; margin: -20px -50px;
              position:relative; top:50%; left:50%;;">Saznaj više</a>



                        </div>
                    </div>
                </div>
                                @endforeach

                            </div>


                        @endforeach

                        <div>{{ $posts->links() }}</div>

                @else
                        <p>There is not posts</p>
                @endif
                          @if (Auth::user())  
                             <a href="{{ route('post.create')}}" class="btn btn-success" style="margin-right: 3px; border-radius:0px; ">Dodaj Vijest</a>
                           @endif
                </div>

table_blade

  <table class="table table-bordered table-striped">

            <thead>
                <tr>
                    <th>Ime Dokumenta</th>
                    <th>Preuzmite Dokument</th>
                  @if (Auth::user())   
                    <th>Obrišite Dokument</th>
                  @endif   
                </tr>
            </thead>

            <tbody>
                @foreach ($documents as $document)

                <tr>
                    <td>{{ $document->title}}</td>
                    <td><a href="{{asset('storage/upload/'.$document->file_name)}}" class="btn btn-hot text-capitalize btn-xs" download>Preuzmi fajl</a>   
                    </td>
                    @if (Auth::user())  
                    <td>
                        <a href="{{ route('document.delete', ['id' =>  $document -> id ]) }}" class="btn btn-hot text-capitalize btn-xs" style="margin-right: 3px;">Obriši</a>
                    </td>
                    @endif
                 @endforeach  

                       </tr> 
            </tbody>

        </table>
    <div>{{ $documents->links() }}</div>

main_page.blade.php

<section id="services">
      <div class="container">
        <div class="row">
          <div class="col-lg-12 text-center">
            <h2 class="section-heading" style="color: #d21826; font-weight: bold;">Vijesti</h2>
            <hr class="my-4">
          </div>
        </div>
      </div>

      <div class="container">

                      @if(session('deletePost')) 
                  <div class="alert alert-danger" role="alert">
                     <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    {{ session('deletePost') }}  


                  </div>
                  @endif

            <div id="tag_container">

    @include('presult')
       </div>   





    </div>     
    </section>

<section class="bg-primary" id="about">
       <div class="container">
        <div class="row">
          <div class="col-lg-12 text-center">
            <h2 class="section-heading" style="color: white; font-weight: bold;">Službeni Dokumenti</h2>
            <hr class="light my-4">
          </div>
        </div>
      </div>
      <div class="container">
        <div class="row">
          <div class="col-lg-12 mx-auto text-center">
                 <div id="table_container" class="table-responsive">
                   @include('table')
                  </div>
          </div>

      </div>
  </div>
           @if (Auth::user())  
                         <a href="{{ route('document.create')}}" class="btn btn-success" style="margin-right: 3px; border-radius:0px; ">Dodaj Vijest</a>
         @endif
</section>

 $(window).on('hashchange', function() {

          if (window.location.hash) {

              var page = window.location.hash.replace('#', '');

              if (page == Number.NaN || page <= 0) {

                  return false;

              }else{

                  getData(page);

              }

          }

      });



  $(document).ready(function()

  {

       $(document).on('click', '.pagination a',function(event)

      {

          event.preventDefault();

          $('li').removeClass('active');

          $(this).parent('li').addClass('active');

          var myurl = $(this).attr('href');

          var page=$(this).attr('href').split('page_1s=')[1];

          getData(page);

      });

  });



  function getData(page){

          $.ajax(

          {

              url: '?page_1s=' + page,

              type: "get",

              datatype: "html"

          })

          .done(function(data)

          {

              $("#tag_container").empty().html(data);

              location.hash = page;

          })

          .fail(function(jqXHR, ajaxOptions, thrownError)

          {

                alert('No response from server');

          });

  }



$(window).on('hashchange', function() {

          if (window.location.hash) {

              var page = window.location.hash.replace('#', '');

              if (page == Number.NaN || page <= 0) {

                  return false;

              }else{

                  getData(page);

              }

          }

      });



  $(document).ready(function()

  {

       $(document).on('click', '.pagination a',function(event)

      {

          event.preventDefault();

          $('li').removeClass('active');

          $(this).parent('li').addClass('active');

          var myurl = $(this).attr('href');

          var page=$(this).attr('href').split('page_2s=')[1];

          getData(page);

      });

  });



  function getData(page){

          $.ajax(

          {

              url: '?page_2s=' + page,

              type: "get",

              datatype: "html"

          })

          .done(function(data)

          {

              $("#table_container").empty().html(data);

              location.hash = page;

          })

          .fail(function(jqXHR, ajaxOptions, thrownError)

          {

                alert('No response from server');

          });

  }