Commonly used in jQuery GetJSON is called to obtain the remote JSON string, convert it into a JSON object, and if successful, execute the callback function. The prototype is as follows: jQuery.getJSON( url, [data], [callback] ) loads JSON data across domains. url: the address to send the request data: (optional) key/value parameters to be sent callback: (optional) callback function when loading is successful is mainly used for the client to obtain the server JSON data. Simple example: Server script, return JSON data:
Note two points: First: before returning to the client, use the PHP function json_encode to encode the returned data. Second: echo is used to return to the client, not return. The following is the core client code: