Home  >  Article  >  Web Front-end  >  Solution to invalid label error when Jquery obtains Json across domains

Solution to invalid label error when Jquery obtains Json across domains

高洛峰
高洛峰Original
2017-06-07 13:49:531381browse

Finally, calm down carefully and read the json official document carefully and find this paragraph:

JSON data is a kind of structured data that can be easily parsed through JavaScript. If the obtained data file is stored on a remote server (with different domain names, that is, cross-domain data acquisition), you need to use the jsonp type. Using this type creates a query string parameter callback=? which is appended to the requested URL. The server should add the callback function name before the JSON data in order to complete a valid JSONP request. If you want to specify the parameter name of the callback function to replace the default callback, you can set the jsonp parameter of $.ajax().

In fact, the principle of jquery's cross-domain is realized through the external link