Answers for "ajax post json data handle in php"

PHP
2

php return json data to ajax

header('Content-Type: application/json'); 

$colors = array("red","blue","green");
echo json_encode($colors);
Posted by: Guest on October-30-2019
0

php json response to ajax

<?php
 echo json_encode($data);
?>
Posted by: Guest on September-08-2020
0

ajax post json data handle in php

// sent json data by post method or others
// {"id":"2"}

header('Content-Type: application/json'); 
// retrieve json data from post 
$json = file_get_contents('php://input'); // return {"id":"2"}
$data = json_encode($json); // return a stdClass object| $data->id
echo $data->id;
Posted by: Guest on October-25-2021

Browse Popular Code Answers by Language