Azeem812
1 month ago
207
6
Laravel

how to access all variable data in in ajax success function ?

Posted 1 month ago by Azeem812

Here is my controller public function detail(Request $request) { $item = DeliverySchedule::find($request->id); $item2 = DeliveryScheduleItem::where('delivery_schedule_id',$item->id)->get(); // updae query accordingly TODO // $rtn = [ // 'status' => $item ? true : false, // 'data' => $item, // ]; $array= array($item,$item2); // echo json_encode($array);

    return response()->json($array, 200);
}

this is ajax request data show in networks

{id: 3, batch_no: "11", color: "Pink", title: "Az3", type: "Regular", vendor_code: null, dc_no: null,…} batch_no: "11" color: "Pink" created_at: "2020-09-23 19:38:43" dc_no: null id: 3 status: null title: "Az3" type: "Regular" updated_at: "2020-09-23 19:38:43" vendor_code: null 1: [{id: 3, delivery_schedule_id: 3, item_id: 1, demand: 33, issued: 0, remarks: null, status: null,…}] 0: {id: 3, delivery_schedule_id: 3, item_id: 1, demand: 33, issued: 0, remarks: null, status: null,…} created_at: "2020-09-23 19:38:44" delivery_schedule_id: 3 demand: 33 id: 3 issued: 0 item_id: 1 remarks: null status: null updated_at: "2020-09-23 19:38:44"

how to show all data in html table ,here is my ajax script $.ajax({ type:'POST', url:'/delivery-schedule/detail', dataType: 'json', data: { _token: _token, id: id }, success:function(result) {

        const item =result.data; 
        console.log(item);

}

Please sign in or create an account to participate in this conversation.