Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php return json data to ajax

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

$colors = array("red","blue","green");
echo json_encode($colors);
Comment

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;
Comment

php json response to ajax


<?php
 echo json_encode($data);
?>

Comment

PREVIOUS NEXT
Code Example
Php :: php numberformatter currency without symbol 
Php :: window.location javascript php 
Php :: php find first occurrence in string 
Php :: laravel validation date 
Php :: laravel select only some columns relationship 
Php :: check if elquent retrun empty array laravel 
Php :: how to get all post fields in wordpress 
Php :: changing created_at to short date time 
Php :: sha256 encryption in php 
Php :: laravel sortby relationship column 
Php :: is dir php 
Php :: contact form 7 remove p 
Php :: upload_max_filesize in wordpress 
Php :: ile_put_contents(/opt/bitnami/apache2/htdocs/bootstrap/cache/services.php): failed to open stream: Permission denied 
Php :: add foreign key in laravel migration 
Php :: add custom style to wordpress editor 
Php :: larave Soft Deletes 
Php :: how to receive json data in php 
Php :: install tymon jwt laravel 
Php :: pdo close connection 
Php :: laravel checking if a record exists 
Php :: laravel delete relationship data 
Php :: mysqli fetch row assoc 
Php :: rand string php 
Php :: failed to open stream permission denied in php 
Php :: 419 page expired laravel 
Php :: php nginx file not found 
Php :: get next month first day php 
Php :: redirect from http to https laravel 
Php :: php set http status header 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =