As some research,
Most commonly 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' => 'stackoverflow'],
];
// Showing the json data
echo json_encode($directory);
?>
Output is,
[{"Id":1, "Name":"this"}, {"Id":2, "Name":"is"}, {"Id":3, "Name":"stackoverflow"}]
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' => 'stackoverflow'],
];
echo "Function_call(".json_encode($dir).");";
?>
Output is,
Function_call([{"Id":1, "Name":"this"}, {"Id":2, "Name":"is"}, {"Id":3, "Name":"stackoverflow"}])
And for other MIME Types see full detail here,
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types