Answers for "php return json response with status code"

PHP
0

php return json response with status code

header('Content-type: application/json');
http_response_code(200);
echo json_encode([
	'message' => 'thanks'
]);
Posted by: Guest on April-29-2022
0

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 },
Posted by: Guest on January-26-2022

Browse Popular Code Answers by Language