我正在尝试使用ajax进行分页,但是当我点击下一页时,它会在我的控制台中显示此错误
jquery-2.2.3.min.js:4 GET http://localhost:8000/patientPanel/ajax/patientHospital?page=2 404 (Not Found)
我也定义了我的路线,但仍然有这个错误。请在下面分享路线,控制器和视图的代码。
控制器
public function index()
{
$hospitals = Hospital::paginate(3);
return View::make('patientPanel/patientHospital')
->with('hospitals',$hospitals);
}
路线
Route::get('/patientPanel/patientHospital', 'patientHospitalController@index');
Route::get('ajax/patienthospital', function(){
$hospitals = Hospital::paginate(3);
return View::make('/patientPanel/patientHospital')
->with('hospitals',$hospitals)->render();
});
查看
<section id="team">
<div class="container">
<div class="row">
@foreach($hospitals as $hospital)
<div class="col-md-3 col-sm-6 col-xs-12 wow fadeIn content" data-
wow-offset="50" data-wow-delay="1.3s">
<div class="team-wrapper">
<img src="/uploads/{{$hospital->picture }}" class="img-responsive" alt="team img 1" style="height: 270px; width: 500px">
<div class="team-des">
<h4>{{$hospital->name}}</h4>
<span>Designer</span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elitquisque tempus ac eget diam et laoreet phasellus ut nisi id leo molest.</p>
</div>
</div>
</div>
@endforeach
</div>
{{$hospitals->links()}}
</div>
</section>
<script type="text/javascript">
$(document).on('click','.pagination a',function(e){
e.preventDefault();
var page = ($(this).attr('href').split('page='))[1];
getProducts(page);
});
function getProducts(page)
{
$.ajax({
url:'/ajax/products?page='+page
}).done(function(data){
$('.content').html(data);
location.hash = page;
});
}
请告诉我为什么我收到此错误,因为我也定义了路线。
答案 0 :(得分:0)
您将路线设为java.lang.RuntimeException:
at android.app.LoadedApk.makeApplication (LoadedApk.java:563)
at android.app.ActivityThread.handleBindApplication (ActivityThread.java:4540)
at android.app.ActivityThread.access$1500 (ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1371)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:135)
at android.app.ActivityThread.main (ActivityThread.java:5268)
at java.lang.reflect.Method.invoke (Method.java)
at java.lang.reflect.Method.invoke (Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:902)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:697)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass (ClassLoader.java:511)
at java.lang.ClassLoader.loadClass (ClassLoader.java:469)
at android.app.Instrumentation.newApplication (Instrumentation.java:980)
at android.app.LoadedApk.makeApplication (LoadedApk.java:558)
并将其设为ajax/patienthospital
从
更改网址/patientPanel/ajax/patientHospital
到
ajax/patienthospital
或者
在路线中添加/patientPanel/ajax/patientHospital
ajax
<强>更新强>
我认为只有Route::get('/patientPanel/ajax/patientHospital',
问题,请与/
/
而不是
/ajax/patienthospital