As some research,
The most common MIME type is
application/json
Let's see a example to differentiate with JSON and JavaScript.
It is used when it is not known how this data will be used. When the information is to be just extracted from the server in JSON format, it may be through a link or from any file, in that case, it is used.
For example-
<?php
header('Content-type:application/json');
$directory = [
['Id' => 1, 'Name' => 'this'],
['Id' => 2, 'Name' => 'is'],
['Id' => 3, 'Name' => 'Stack Overflow'],
];
// Showing the JSON data
echo json_encode($directory);
?>
The output is,
[{"Id":1, "Name":"this"}, {"Id":2, "Name":"is"}, {"Id":3, "Name":"Stack Overflow"}]
It is used when the use of the data is predefined. It is used by applications in which there are calls by the client-side Ajax applications. It is used when the data is of type JSON-P or JSONP.
For example
<?php
header('Content-type:application/javascript');
$dir = [
['Id' => 1, 'Name' => 'this' ],
['Id' => 2, 'Name' => 'is'],
['Id' => 3, 'Name' => 'Stack Overflow'],
];
echo "Function_call(" . json_encode($dir) . ");";
?>
The output is,
Function_call([{"Id":1, "Name":"this"}, {"Id":2, "Name":"is"}, {"Id":3, "Name":"Stack Overflow"}])
And for other MIME types, see the full detail in MIME types (IANA media types).