JSONP is JSONwithPadding. Due to the same-origin policy restrictions, XmlHttpRequest only allows requests to resources of the Current Source (domain name, protocol, port. Principle: JSONP is JSON with Padding. Due to the same-origin policy restrictions, XmlHttpRequest only allows requests to resources of the Current Source (domain name, protocol, port. For cross-origin requests, we can use the html script tag to perform cross-origin requests, and return the script code to be executed in the response, where javascript objects can be directly transmitted using JSON. This cross-origin communication method is called JSONP.
Personal Understanding:
It is to dynamically register a function a (data) on the client, and then upload the function name to the server. The server returns a ({/* json */}) to run on the client, in this way, function a (data) of the client is called to implement cross-origin.
The Code is as follows:
Test Jsonp