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 date add days 
Php :: php flatten multidimensional array 
Php :: format date in php 
Php :: PHP not working centos 8 
Php :: Laravel 5.4 Route back in blade 
Php :: alerta con php 
Php :: php check if folder exists 
Php :: applying multiple order by in codeigniter 
Php :: wordpress exclude current post from loop 
Php :: curl in laravel 
Php :: mysql secure 
Php :: where is the php ini file located on server 
Php :: clear laravel.log 
Php :: laravel duplicate row 
Php :: laravel check if exists in table 
Php :: Yii::app()-request-get yii1 
Php :: echo ternary php 
Php :: php program to find factorial of a number using function 
Php :: php get highest key in array 
Php :: how get query logs in laravel 
Php :: lodash tester 
Php :: collapse open by default 
Php :: laravel make component inline 
Php :: Fetch Multiple Rows in PHP 
Php :: program logic for second largest number in an array in php 
Php :: php random characters 
Php :: laravel assets path 
Php :: query string in laravel 
Php :: Add ... if string is too long PHP 
Php :: db name laravel 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =