this is my controller code
$website = Website_links::where('website_id', $id)
->Paginate(5);
$websites = Website::where('id',$id)->first();
if (Request::ajax()) {
return Response::json(View::make('user.project.audit_content', array('data'=>$website))->render());
}
return View::make('user.project.audit_content', array('data'=>$website));
and this is javascript pagination code
$(window).on('hashchange', function() {
if (window.location.hash) {
var page = window.location.hash.replace('#', '');
if (page == Number.NaN || page <= 0) {
return false;
} else {
getPosts(page);
}
}
});
$(document).ready(function() {
$(document).on('click', '#link a', function (e) {
getPosts($(this).attr('href').split('page=')[1]);
e.preventDefault();
});
});
function getPosts(page) {
$.ajax({
url : '?page=' + page,
dataType: 'json',
}).done(function (data) {
$('.page-wrraper ').html(data);
location.hash = page;
}).fail(function () {
alert('Posts could not be loaded.');
});
}
and this is my view
@extends('layouts.master')
@section('content')
<div class="main-wrapper nopad-lr ">
<!-- .......................................................................
top section
...........................................................................-->
@include('layouts.topnav')
@include('layouts.smallnav2')
<!-- .......................................................................
Left section
...........................................................................-->
<div class="left-sec">
@include('layouts.sidebar',['active'=>$active])
</div>
<!-- .......................................................................
Right section
...........................................................................-->
<div class="right-sec">
{{--@include('layouts.topnav')--}}
@include('layouts.innernav')
<!--.................................... ......................................right conent....................................... -->
<div class="page-wrraper clear">
{{--@include('layouts.innernav')--}}
<div class=" main-table audit-meta clear">
<table class="table table-blue">
<thead>
<tr>
<th style="border-bottom:1px solid transparent">Page Title & Canonical URL</th>
<th style=";text-align: center;" colspan="2">Links</th>
<th style="width: 150px;border-bottom:1px solid transparent">Words Count</th>
<th style="width: 76px;border-bottom:1px solid transparent" >Action</th>
</tr>
<tr>
<th ></th>
<th style="width: 150px;text-align: center;" >External</th>
<th style="width: 150px;text-align: center;" >Internal</th>
<th ></th>
<th ></th>
</tr>
</thead>
<tbody>
@foreach($data as $meta)
<tr>
<td>{{$meta->meta_title}}
<a href="{{$meta->page_url}}" target="_blank">{{$meta->page_url}}</a></td>
<td>{{count($meta->type_external)}}</td>
<td>{{count($meta->type_internal)}}</td>
<td>2324</td>
<td>
<ul class="option-menu">
<li class="selected"><a><i class="icon-action_report"></i></a>
<ul class="option-dropdown">
<li>
<a href=""><i class="icon-action_report"></i>Re-Crawl</a>
</li>
<li>
<a href=""><i class="icon-action_report"></i>Navigate</a>
</li>
</ul>
</li>
</ul>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="clearfix"></div>
<div id="link" class="pagination-sec">
{!! $data->links() !!}
</div>
</div>
<!-- .....................................................................right conent end....................................... -->
</div>
<div class="clearfix"></div>
</div>
@stop
now pagination work correct and page does not refresh but this code replacing whole page in to div which class=page-wrapper and blink 2 or 3 time.mean i am getting sidebar top nav etc in div which class=page-wrapper.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire