This time I will bring you the method and method of Jquery cross-domain obtaining Json. What are the precautions for Jquery cross-domain obtaining Json. The following is a practical case, let's take a look.
When using Jquery to retrieve data across domains in the past two days, I often encountered the error invalid label. It was very frustrating. I could never get the json value sent back by the server.
The two methods generally used across domains are: $.ajax and $.getJSON
Finally, calm down carefully and read the json official document and found 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 in front of 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 external links