Answers for "php request and response json"

7

php return json

header('Content-type: application/json');
echo json_encode($array);
Posted by: Guest on March-20-2020
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

Code answers related to "php request and response json"

Code answers related to "Javascript"

Browse Popular Code Answers by Language