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 :: get only the first two word from a string php 
Php :: General error: 1390 Prepared statement contains too many placeholders 
Php :: Laravel Framework upgrade from older version 7.x to 8.x 
Php :: php line break 
Php :: laravel use variable inside callback function 
Php :: laravel response header 
Php :: filter child table data from parent laravel eloquent 
Php :: php http authentication 
Php :: diffinhours with minutes carbon 
Php :: laravel model events 
Php :: php check if string contains url 
Php :: Laravel Eloquent Query Using WHERE with OR AND OR? 
Php :: laravel attach once 
Php :: print in php 
Php :: Diferencia entre dias PHP 
Php :: where in laravel 
Php :: Creating default object from empty value 
Php :: implode example in php 
Php :: wordpress admin url 
Php :: laravel activity log 
Php :: wherein elequent 
Php :: check website ssl certificate using php 
Php :: php http errorcode 
Php :: php italian date 
Php :: what does defined di in php 
Php :: json to html php table 
Php :: null value in php 
Php :: check if post exists by id wordpress 
Php :: advantages of php 
Php :: laravel mysql specified key was too long 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =