Home > Web Front-end > JS Tutorial > Jsonp cross-domain principle and Jquery solution_jquery

Jsonp cross-domain principle and Jquery solution_jquery

WBOY
Release: 2016-05-16 18:05:46
Original
798 people have browsed it

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:
It 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 for running, like this Just call the client's function a(data), thereby achieving cross-domain.

Copy the code The code is as follows:




Test Jsonp










jquery’s jsoncallback is dynamically generated Yes, the address of the actual request server: http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=jsonp1274058545738
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template