jsonp solve cross-domain data acquisition

jsonp not json, json is a data exchange format, a data exchange jsonp.

jsonp use principle: html tag with the src attribute will support cross-domain access, for example, img, a, iframe, video and so on the label.

The client calls the server-side function of the same name, the same name as the server to get data returned by the function (usually json format) to complete the entire call flow

Client url path of the request in general will keep some parameters, (https: // xxxxx / yyy / zz code = xxx & callback = xxx?) Such as callback = xxx, xxx, which represents the same name as a function of the server needs to be generated, code = xxx is carried in the request parameter

Receives service requests, according to the code created with the same name and callback function and the function of the same name at this time in accordance with the parameters of the server to obtain the data, the function of the same name wrap parameter acquisition data (usually converted into the data format json) returned by, you can do some other operations.

Guess you like

Origin www.cnblogs.com/yjp372928571/p/11275066.html