php return json data to ajax
header('Content-Type: application/json');
$colors = array("red","blue","green");
echo json_encode($colors);
php return json data to ajax
header('Content-Type: application/json');
$colors = array("red","blue","green");
echo json_encode($colors);
php json response to ajax
<?php
echo json_encode($data);
?>
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;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us