0
JSON響應,這是我的控制器:如何返回laravel
public function index(Request $request)
{
$items = Post::latest()->paginate(5);
$cmnt=Comment::all();
return response()->json(array('posts'=>$items,'comment'=>$cmnt));
}
**這是我的Ajax請求**
function getPageData() {
$.ajax({
dataType: 'json',
url: "{{route('post_status.index')}}",
data: {page:1}
}).done(function(data){
manageRow(data.data);
});
}
function manageRow(data) {
console.log(data.comment);
}
爲什麼我收到錯誤? 幫我出這個plzz
「爲什麼我收到錯誤」 __What__錯誤? – tkausl
實際上它沒有顯示任何內容.....沒有任何價值 – leo
@leo你有沒有試過在控制檯上看?同樣在你對評論的回答中,你會談論多個對象?你能真正解釋你在你的問題中想做什麼嗎? –