Finally, take a closer look and read the official json document to find the following paragraph:
JSON data is a structured data that can be easily parsed using JavaScript. If the obtained data file is stored on a remote server (the domain name is different, that is, cross-Origin data retrieval), The jsonp type is required. If this type is used, a query string parameter callback =? will be created? This parameter is added after the request URL. The server should add the callback function name before the JSON data to complete a valid JSONP request. If you want to specify the callback function parameter name to replace the default callback, you can set the jsonp parameter of $. ajax.
In fact, the cross-origin principle of jquery is implemented through the external chain <script>, and then the callback function parameters are added to realize the real cross-origin.
Jquery will have the callback parameter each time it sends a request across domains. In fact, the value of this parameter is the name of the callback function. Therefore, when sending json data, the server should put this parameter in front, the value of this parameter is often randomly generated, for example, jsonp129472138682. You can also use $. set the name of the callback method in ajax. After understanding the principles, the server should send data as follows:
String message = "Maid ({\" userid \ ": 0, \" username \ ": \" null \"})";
In this way, json data {\ "userid \": 0, \ "username \": \ "null \"} is used as a parameter of the jsonp129472138682 callback function.
Solution to invalid label when obtaining Json from cross-origin:
When the server outputs Json data, add the callback parameter value, for example, jsonp129472138682 ({\ "userid \": 0, \ "username \": \ "null \"})