Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php return json response with status code

header('Content-type: application/json');
http_response_code(200);
echo json_encode([
	'message' => 'thanks'
]);
Comment

php return a json response

//PHP File
<?php
$data = /** whatever your data are **/;
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data);

//In JS File
//JQUERY AJAX
        $.ajax({
        url: "path/to_php_file.php",
        dataType: "json",  
        type: "GET",
        data: {datax : datax },
Comment

PREVIOUS NEXT
Code Example
Php :: install ext-ldap php 7.2 
Php :: how to separate date and time in laravel 
Php :: how to remove additional sidebar in magento 2 using xml 
Php :: laravel debug 
Php :: get all errors view laravel 
Php :: generating-random-token-php 
Php :: php serve 
Php :: php make array to certain length 
Php :: how to write json to file in php 
Php :: concat in laravel 8 
Php :: laravel active nav 
Php :: Laravel Unable to migrate or Make Seeds 
Php :: php ini ubuntu 
Php :: convert object to array laravel 
Php :: wordpress throw to debug.log 
Php :: wordpress get user by id 
Php :: fore install debian 10 php 7.3 
Php :: seconds to days hours minutes seconds php 
Php :: serialize() php 
Php :: php pass variable to anonymous function 
Php :: htmlspecialchars() expects parameter 1 to be string 
Php :: laravel blade get authenticated user email 
Php :: order number generate laravel 
Php :: wordpress echo the date in post 
Php :: array_search 
Php :: laravel validate unique column 
Php :: laravel get auth user in constructor 
Php :: debug $_POST 
Php :: wpdb-prepare 
Php :: php hash password using bcrypt 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =