Home >Web Front-end >JS Tutorial >Jsonp cross-domain principle and Jquery solution_javascript skills
Principle: JSONP is JSON with Padding. Due to the restrictions of the same-origin policy, XmlHttpRequest is only allowed to request resources from the current source (domain name, protocol, port). If we want to make a cross-domain request, we can make a cross-domain request by using the script tag of html and return the script code to be executed in the response, where the javascript object can be passed directly using JSON. This cross-domain communication method is called JSONP.
Personal understanding:
is to dynamically register a function a(data) on the client, and then pass the function name to the server, and the server returns a({/*json*/}) to the client Run, thus calling the client's function a(data), thus achieving cross-domain.