I see that you can use several but I do not understand their differences or when I should use one or the other, for example:
text/javascript
text/x-javascript
text/x-json
application/json
application/x-javascript
I see that you can use several but I do not understand their differences or when I should use one or the other, for example:
text/javascript
text/x-javascript
text/x-json
application/json
application/x-javascript
According to section 11 of the RFC7159: The JavaScript Object Notation (JSON) Data Interchange Format is correct is application/json
:
11. IANA Considerations The MIME media type for JSON text is application/json. Type name: application Subtype name: json
In the case of the others the uses are the following:
text/javascript
It's obsolete, do not use it text/x-javascript
It was an experimental content-type, neither should it be used. text/x-json
Also experimental. Do not use it application/x-javascript
. Do not use it It is also worth mentioning that an alternative that is not mentioned is x-
. This content-type must be used for JavaScript not to be confused with JSON .
As far as I know, if you are going to transmit JSON through an HTTP service, you should use the content type application/json
and it is supported by the official standard internet protocol RFC 4627
For JSON
pure% you should use application/json
and for the case of JSONP
you should use application/javascript