title: Avoid refreshing the page at pagination
body: <p>I want to avoid refreshing page when i switch the pages using pagination from Laravel because when I switch the page from 1 to page 2, It redirects to the parent page. How can I avoid reloading page when i switch the pages? I have 2 tabs at <code>Invitation</code> - <code>Received</code> and <code>Initiated</code>. On <code>Initiated</code>, I have pagination, when i press on page 2 for example, I get redirected to the parent page which is <code>Invitation</code>, I need to stay on the page <code>Initiated</code> when i switch the page from pagination.</p>
  
  <p><em>Here is my controller:</em></p>
  
  <pre class="lang-php prettyprint-override"><code>$initiated =  \App\Invitation::with('user')
      -&gt;where('inviter_id', Sentinel::getUser()-&gt;id)
      -&gt;orderBy('id', 'desc')
      -&gt;paginate(6);
  </code></pre>
  
  <p><em>Here is my view:</em></p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div id="initiated" class="profile-edit tab-pane fade" style="background: none repeat scroll 0 0;"&gt;
      &lt;dl class="dl-horizontal"&gt;
          &lt;ul class="nav justify-content-center u-nav-v5-3 u-nav-primary  " role="tablist"
              data-target="nav-5-3-primary-hor-center" data-tabs-mobile-type="slide-up-down"
              data-btn-classes="btn btn-md btn-block u-btn-outline-primary"
              style="display: flex;justify-content: flex-end;"&gt;
              &lt;li class="nav-item active"&gt;
                  &lt;a a data-toggle="tab" href="#grid" style="font-size: 12px"&gt;&lt;i class="fa fa-th-large"&gt;&lt;/i&gt; Grid&lt;/a&gt;
              &lt;/li&gt;
              &lt;li class="nav-item"&gt;
                  &lt;a a data-toggle="tab" href="#list" style="font-size: 12px"&gt;&lt;i class="fa fa-bars"&gt;&lt;/i&gt; List&lt;/a&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
          &lt;div class="tab-content"&gt;
              &lt;div id="grid" class="tab-pane fade in active"&gt;
                  &lt;?php $count_user = 0;
           ?&gt;
                  @foreach($initiated as $record)
                  @if($count_user == 0)
                  &lt;div class="row margin-bottom-20 "&gt;
                      @endif
                      &lt;?php $count_user++; ?&gt;
                      &lt;div class="col-sm-6 sm-margin-bottom-20"&gt;
                          &lt;div class="profile-blog"&gt;
                              &lt;img style="border-radius: 0% !important" class="rounded-x"
                                  src="{{ asset('thumbnail') }}/{{ $record-&gt;user ? $record-&gt;user-&gt;profile_picture : '' }}"
                                  alt=""&gt;
                              &lt;div class="name-location" style="top: 30px;position: relative"&gt;
                                  @if($record-&gt;user-&gt;role[0]-&gt;slug == 'individuals' ? $record-&gt;user-&gt;role[0]-&gt;slug : '')
                                  &lt;i style="font-size: 13px;position: relative;" class="icon-user"&gt;&lt;/i&gt;
                                  @elseif($record-&gt;user-&gt;role[0]-&gt;slug == 'organizations' ? $record-&gt;user-&gt;role[0]-&gt;slug :
                                  '')
                                  &lt;i style="font-size: 13px;position: relative;"
                                      class="icon-hotel-restaurant-172 u-line-icon-pro fa- fa-lg"&gt;&lt;/i&gt;
                                  @endif
                                  &lt;a id="my-link" style="color: #555;text-decoration: none;font-size: 16px"
                                      href="{{ url('') }}/{{ $record-&gt;user ? $record-&gt;user-&gt;username : '' }}"&gt;{{ $record-&gt;user ? $record-&gt;user-&gt;username : '' }}&lt;/a&gt;
                                  &lt;/h3&gt;
                              &lt;/div&gt;
                              &lt;div class="clearfix "&gt;&lt;/div&gt;
                              &lt;strong style="font-size: 13px"&gt;&lt;i style="padding: 5px"
                                      class="icon-real-estate-020 u-line-icon-pro"&gt;&lt;/i&gt;Location :
                              &lt;/strong&gt;{{ $record-&gt;user ? $record-&gt;user-&gt;country-&gt;country : '' }} &lt;span
                                  class="{{ $record-&gt;user ? $record-&gt;user-&gt;country-&gt;flag : '' }}"&gt;&lt;/span&gt;&lt;br&gt;
                              &lt;strong style="font-size: 13px"&gt;&lt;i style="padding: 5px"
                                      class="icon-notebook fa-"&gt;&lt;/i&gt;Industry :
                              &lt;/strong&gt;{{ $record-&gt;user ? $record-&gt;user-&gt;industry-&gt;industry : '' }}&lt;br&gt;
                              @if($record-&gt;user-&gt;role[0]-&gt;slug == 'organizations' ? $record-&gt;user-&gt;role[0]-&gt;slug : '')
                              @if(isset($record-&gt;user-&gt;organization_type-&gt;organization_type))
                              &lt;strong style="font-size: 13px"&gt;&lt;i
                                      class="icon-hotel-restaurant-172 u-line-icon-pro fa- fa-lg"
                                      style="padding: 5px;font-size: 13px"&gt;&lt;/i&gt;Organization :
                              &lt;/strong&gt;{{ $record-&gt;user ? $record-&gt;user-&gt;organization_type-&gt;organization_type : '' }}@endif
                              @endif
                              @if($record-&gt;user-&gt;role[0]-&gt;slug == 'individuals' ? $record-&gt;user-&gt;role[0]-&gt;slug : '')
                              @if(!empty($record-&gt;user-&gt;career_path[0]))
                              &lt;strong style="font-size: 13px"&gt;&lt;i class="icon-speedometer"
                                      style="padding: 5px"&gt;&lt;/i&gt;Function :
                              &lt;/strong&gt;{{ $record-&gt;user ? $record-&gt;user-&gt;career_path[0]-&gt;functions-&gt;function : '' }}@endif
                              @endif
                              &lt;hr&gt;
                              &lt;ul class="list-inline share-list"&gt;
                                  &lt;li&gt;
                                      &lt;a href="/cancel-invitation/{{$record-&gt;id}}"&gt;&lt;i class="fa fa-times"&gt; &lt;/i&gt;Cancel&lt;/a&gt;
                                  &lt;/li&gt;
                              &lt;/ul&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      @if($count_user == 2)
                  &lt;/div&gt;
                  &lt;?php  $count_user = 0; ?&gt;
                  @endif
                  @endforeach
              &lt;/div&gt;
              &lt;div id="list" class="tab-pane fade"&gt;
                  &lt;?php $count_user = 0;
           ?&gt;
                  @foreach($initiated as $record)
                  @if($count_user == 0)
                  &lt;div class="row"&gt;
                      @endif
                      &lt;?php $count_user++; ?&gt;
                      &lt;div class="col-sm-12 sm-margin-bottom-20" style="margin-bottom: 12px"&gt;
                          &lt;div class="profile-blog" style="padding: 5px"&gt;
                              &lt;img style="margin-right: 10px"
                                  src="{{ asset('thumbnail') }}/{{ $record-&gt;user ? $record-&gt;user-&gt;profile_picture : '' }}"
                                  alt=""&gt;
                              &lt;div class="name-location"&gt;
                                  &lt;h3&gt; @if($record-&gt;user-&gt;role[0]-&gt;slug == 'individuals' ? $record-&gt;user-&gt;role[0]-&gt;slug :
                                      '')
                                      &lt;i style="font-size: 13px;position: relative;" class="icon-user"&gt;&lt;/i&gt;
                                      @elseif($record-&gt;user-&gt;role[0]-&gt;slug == 'organizations' ?
                                      $record-&gt;user-&gt;role[0]-&gt;slug : '')
                                      &lt;i style="font-size: 13px;position: relative;"
                                          class="icon-hotel-restaurant-172 u-line-icon-pro fa- fa-lg"&gt;&lt;/i&gt;
                                      @endif &lt;a id="my-link" style="color: #555;text-decoration: none;font-size: 16px"
                                          href="{{ url('') }}/{{ $record-&gt;user ? $record-&gt;user-&gt;username : '' }}"&gt;{{ $record-&gt;user ? $record-&gt;user-&gt;username : '' }}&lt;/a&gt;
                                  &lt;/h3&gt;
                                  &lt;ul class="list-inline share-list d-flex pull-right"
                                      style="bottom: 25px;position: relative;margin-bottom: -20px;left: -25px"&gt;
                                      &lt;li style="left: 25px;position: relative"&gt;
                                          &lt;a href="/cancel-invitation/{{$record-&gt;id}}"&gt;&lt;i
                                                  class="icon-custom-me rounded fa fa-times"&gt; &lt;/i&gt;&lt;/a&gt;
                                      &lt;/li&gt;
                                  &lt;/ul&gt;
                              &lt;/div&gt;
                              &lt;div style="display: flex;right: 2px;position: relative;bottom: 12px;margin-bottom: -10px"&gt;
                                  &lt;div style="padding-right: 15px"&gt;
                                      &lt;strong&gt;&lt;i class="icon-real-estate-020 u-line-icon-pro"&gt;&lt;/i&gt; :
                                      &lt;/strong&gt;{{ $record-&gt;user ? $record-&gt;user-&gt;country-&gt;country : '' }} &lt;span
                                          class="{{ $record-&gt;user ? $record-&gt;user-&gt;country-&gt;flag : '' }}"&gt;&lt;/span&gt;
                                  &lt;/div&gt;
                                  &lt;div style="padding-right: 10px"&gt;
                                      &lt;strong&gt;&lt;i class="icon-screen-tablet fa-"&gt;&lt;/i&gt; :
                                      &lt;/strong&gt;{{ $record-&gt;user ? $record-&gt;user-&gt;industry-&gt;industry : '' }}
                                  &lt;/div&gt;
                                  &lt;div style="padding-right: 10px"&gt;
                                      @if($record-&gt;user-&gt;role[0]-&gt;slug == 'organizations' ? $record-&gt;user-&gt;role[0]-&gt;slug :
                                      '')
                                      @if(isset($record-&gt;user-&gt;organization_type-&gt;organization_type))
                                      &lt;strong&gt;&lt;i class="icon-speedometer"&gt;&lt;/i&gt; :
                                      &lt;/strong&gt;{{ $record-&gt;user ? $record-&gt;user-&gt;organization_type-&gt;organization_type : '' }}
                                      @endif
                                      @endif
                                  &lt;/div&gt;
                                  &lt;div style="padding-right: 10px"&gt;
                                      @if($record-&gt;user-&gt;role[0]-&gt;slug == 'individuals' ? $record-&gt;user-&gt;role[0]-&gt;slug :
                                      '')
                                      @if(!empty($record-&gt;user-&gt;career_path[0]))
                                      &lt;strong&gt;&lt;i class="icon-frame fa-"&gt;&lt;/i&gt; :
                                      &lt;/strong&gt;{{ $record-&gt;user ? $record-&gt;user-&gt;career_path[0]-&gt;functions-&gt;function : '' }}
                                      @endif
                                      @endif
                                  &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;/ul&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      @if($count_user == 2)
                  &lt;/div&gt;
                  &lt;?php  $count_user = 0; ?&gt;
                  @endif
                  @endforeach
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/dl&gt;
      {!! $initiated-&gt;render() !!}
  &lt;/div&gt;
  </code></pre>
  
  <p><em>Here is my Ajax:</em></p>
  
  <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $('.pagination a').on('click', function (e) {
      e.preventDefault();
      var url = $(this).attr('href');
      $('#initiated').load(url + ' div#initiated');
  });
  &lt;/script&gt;
  </code></pre>