我正在使用Laravel 5.3并且遇到了这个错误。
author_page.blade.php
<script>
$(document).ready(function() {
$.ajax({
type: 'get',
url: '/authors_detail',
contentType: 'application/json',
data: '',
success: function(data) {
$('h1#author_page_url').html(data.bio[0].upload_pic)
$('div#about_us').html(data.bio[0].aboutus_body)
}
});
});
</script>
AjaxOperationController
public function author_detail($id)
{
$author_id= Get::findOrFail($id);
echo "author detail". $author_id;
$author_bio=DB::select('select * from author_profile where
author_id = ?', [$author_id]);
return response()->json(array('bio'=>$author_bio),200);
}
routes.php文件
Route::get('author_page/{id}','AjaxOperationController@author_detail');