When the server returns JSON-formatted data to the browser end, the following code is used:
Response.setcontenttype ("Text/javascript;charset=utf-8");
Response.setcontenttype ("Application/json;charset=utf-8");
Difference:
Text/javascript is used to return the JS code, Application/json specifically used to return data in JSON format.
The JS code returned by the former is automatically executed in the browser, just as the result of the return is called by Eval. That is to say the returned string, will be used as JS code, the browser's JS engine to carry out. Instead of being displayed as a normal string in the browser.
The JS code returned by the former is automatically executed in the browser, just as it was called by eval (result). The code written back to the browser is processed as JS, which is specifically used to return the JSON string.
JSON-formatted data is also a JS string that is parsed by the browser as a JSON object and returns the JSON string, both of which apply.
Overall:
Server-side---->>>> clients send JSON data
Response.setcontenttype ("Text/javascript;charset=utf-8");
Response.setcontenttype ("Application/json;charset=utf-8");
Client sends JSON data----->>>> Server:
content-type = ' application/json;charset=utf-8 '
content-type = ' Text/json;charset=utf-8 '
content-type = ' text/javascript;charset=utf-8 '
content-type = ' application/ Javascript;charset=utf-8 '