Good evening, please tell me how in js (using jQuery) through ajax to transfer the data of the array structure from the php file in json format and put this data into a table?
In the condition with loadTasks, all the data from php should be unloaded, there will be more sorting, but for now I would like to understand how easy it is to get the data some example?
index.html
<div class="container"> <div class="table-responsive"> <table class="table"> <thead> <tr> <th>Name:</th> <th>Type:</th> <th>Date:</th> <th>Status:</th> </tr> </thead> <tbody> </tbody> </table> </div> </div> func.php
<?php $tasks = [ [ 'id' => '4', 'name' => 'Task 4', 'type' => 'frontend', 'date' => '1512403290', 'status' => '0', ], [ 'id' => '5', 'name' => 'Task 5', 'type' => 'frontend', 'date' => '1512403320', 'status' => '0', ], [ 'id' => '6', 'name' => 'Task 6', 'type' => 'backend', 'date' => '1512403350', 'status' => '1', ], [ 'id' => '2', 'name' => 'Task 2', 'type' => 'frontend', 'date' => '1512403200', 'status' => '0', ], [ 'id' => '3', 'name' => 'Task 3', 'type' => 'frontend', 'date' => '1512403230', 'status' => '0', ], [ 'id' => '1', 'name' => 'Task 1', 'type' => 'backend', 'date' => '1512403260', 'status' => '1', ], ]; switch($_REQUEST['function']) { case 'loadTasks': $result = []; if($_REQUEST['type'] == '' || $_REQUEST['type'] == 'all'){ echo json_encode($tasks); die(); } foreach($tasks as $task){ if($task['type'] == $_REQUEST['type']){ $result[] = $task; } } echo json_encode($result); break; case 'deleteTask': if(empty($_REQUEST['id'])){ echo 0; die(); } // code delete task echo 1; break; case 'editTask': if(empty($_REQUEST['id']) || empty($_REQUEST['type']) || empty($_REQUEST['name'])){ echo 0; die(); } // code edit task echo 1; break; }?>