Php returned json format problem

php


$arr = [
        "errNo" => 0,
        "errstr" => "success",
        "data" => [

                "list" => [],
        ],

Header("Content-type:application/json; charset=UTF-8");
echo json_encode($arr);

other people"s website:

clipboard.png

:

clipboard.png

what is the reason for this?

Php
Mar.07,2022

actually comes from the same thing. As long as it is not the first data to be loaded, there will be a color reminder, such as Ajax data

.

data.php

<?php
$arr = [
        'errNo' => 0,
        'errstr' => 'success',
        'data' => [

                'list' => [],
        ]
];
header('Content-Type:application/json;');
echo json_encode($arr);

Front

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
axios.get('/data.php')
  .then(function (response) {
    console.log(response.data);
  });
</script>

result

clipboard.png


need to confirm what the content-type in response header is

Menu