۴۰۴ Not Found! قیمت ها به ۴۰۳ برگشت! به مدت محدود!
بزن بریم!با سلام.من میخواستم مطالب به صورت صفحه بندی شده با ajax نشون بدم که برای دفعه اول خوب کارمیکنه وهمین که از صفحه 1 به بقیه صفحات رفت دیگه کار نمیکنه کدامو میزارم ممنون میشم کمک کنید
route::prefix('admin/services/cv_card/blog/articles')->middleware('auth')->group(function(){
route::get('/index','back\services\cv_card\blog\ArticleController@index')->name('admin.services.cv_card.blog.articles');
route::get('/pagination/fetch_data','back\services\cv_card\blog\ArticleController@fetch_data')->name('admin.services.cv_card.blog.article.fetch_data');
route::get('/status/{article}','back\services\cv_card\blog\ArticleController@updatestatus')->name('admin.services.cv_card.blog.article.status');
});
public function index()
{
$categories = Category::get();
$articles=Article::paginate(5);
return view('back.service.cv-card.blog.article.index',compact('articles','categories'));
}
function fetch_data(Request $request)
{
if($request->ajax())
{
$articles=Article::where('user_id','=',auth()->user()->id)->paginate(5);
return view('back.service.cv-card.blog.article.articles_table',compact('articles'))->render();
}
}
$(".page-link").click(function(event) {
event.preventDefault();
var page = $(this).attr('href').split('page=')[1];
fetch_data(page);
});
/////////////////////serices codes
function fetch_data(page)
{
$.ajax({
url: '/admin/services/cv_card/blog/articles/pagination/fetch_data?page='+page,
// beforeSend:function() {
// $("#blogCreateBtn").addClass("disabled");
// $("#blogCreateBtn").text("در حال پردازش");
// },
success:function(data)
{
$('#articles_table').html(data);
}
});
}
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead>
<tr>
<th>#</th>
<th>عنوان</th>
<th>بدنه</th>
<th>مدیریت</th>
</tr>
</thead>
<tbody>
@php
$count = (($articles->currentPage()-1) * ($articles->perPage()))+1 ;
@endphp
@foreach ($articles as $article)
<tr>
<th scope="row">{{$count}}</th>
<td>{{$article->name}}</td>
<td>{{strip_tags(substr($article->description,0,50))}}</td>
<td>
<button type="button" class="btn btn-warning" onclick="updateBlogModal({{$article.','.$article->categories}})" data-toggle="modal" data-target="#edit-blog" > ویرایش</button>
<a href="javascript:void(0);" onclick="deleteBlog({{$article->id}})" class="btn btn-danger btn-sm"> حذف </a></td>
</tr>
@php
$count++;
@endphp
@endforeach
</tbody>
</table>
@include('back.service.cv-card.blog.article.paginate')
</div> <!-- end table-responsive-->
<div class="col-lg-12">
<div class="card-box">
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#create-bolg">ایجاد بلاگ</button><br>
<h4 class="header-title"></h4>
<p class="sub-header">
<div class="result"></div>
</p>
<div id="articles_table">
@include('back.service.cv-card.blog.article.articles_table')
</div>
</div> <!-- end card-box -->
</div> <!-- end col -->
<div class="row">
<div class="col-12">
<ul class="pagination pagination-rounded justify-content-end mb-3">
@if ($articles->hasPages())
@if (!$articles->onFirstPage())
<li class="page-item">
<a class="page-link ff" href="{{$articles->previousPageUrl()}}" aria-label="Previous">
<span aria-hidden="true">«</span>
<span class="sr-only">قبلی</span>
</a>
</li>
@endif
<?Php $count=$articles->currentPage();?>
@for ($i = $count-2 ; $i < $count ; $i++)
@if ($i > 0)
<li class="page-item"><a class="page-link ff" href="{{$articles->url($i)}}">{{$i}}</a></li>
@endif
@endfor
<li class="page-item active"><a class="page-link ff" >{{$articles->currentPage()}}</a></li>
@for ($i = $count+1 ; $i < $count+3 ; $i++)
@if ($i < $articles->lastPage())
<li class="page-item"><a class="page-link ff" href="{{$articles->url($i)}}">{{$i}}</a></li>
@endif
@endfor
@if ($articles->hasMorePages())
<li class="page-item"><a class="page-link ff" >...</a></li>
<li class="page-item"><a class="page-link ff" href="{{$articles->url($articles->lastPage())}}">{{$articles->lastPage()}}</a></li> <li class="page-item">
<a class="page-link ff" href="{{$articles->nextPageUrl()}}" aria-label="Next">
<span aria-hidden="true">»</span>
<span class="sr-only">بعدی</span>
</a>
</li>
@endif
@endif
</ul>
</div> <!-- end col-->
</div>
به جای استفاده از سلکت کلاس از فراخوانی رویداد با onclick به المنت مورد نظرت استفاده کن
$(".page-link").click(function(event) {
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟