This blog post all about How to return multiple value from PHP page from ajax call. Here developers need to return value JSON format, and send to value from ajax call it need to set dataType as JSON. You can see the small example given below. This code snippet from my working code. Ignore the $_POST variable and Table name In order to providing you an example .
ajax_page.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | if(isset($_POST['fetch_attendance']) && $_POST['fetch_attendance']='2'){ $sql='SELECT * from attendance where aid="'.$_POST['aid'].'"'; $result1 = mysqli_query($conn, $sql); if ($result1->num_rows > 0) { while($row1 = $result1->fetch_assoc()) { $items[]=$row1; } $data=array("msg"=>"sucess","code"=>"200","items"=>$items); }else{ $data=array("msg"=>"No data found","code"=>"404"); } print_r(json_encode($data));exit; } |