Home > Web Front-end > JS Tutorial > My opinion on JSONP_json

My opinion on JSONP_json

WBOY
Release: 2016-05-16 16:07:48
Original
1007 people have browsed it

I am new to JavaScript, so I have a little bit of my own understanding. Please correct me if I find anything inappropriate~

JSONP:

The method used when local html files want to obtain xxx website (cross-domain) data.

Cross-domain issues:

Data from external servers can only be accessed using js in the external server, and local js cannot be accessed using XMLHttpRequest().

The web service in the external server provides JSON data, such as in http://gumball.wickedlysmart.com/, the data is included as a parameter in the function updateSales, and now it is accessed externally in local html What to do with the JSON data in the server?

1. Check the Web service document and clarify the parameter name actually used by the service (in this example, there is only one parameter, which is an object array);
2. Specify a callback function in the url, http://gumball.wickedlysmart.com/?callback=updateSales, which is used to specify the function name for accessing JSON data in the web service;
3. Create the function updateSales (object) in the local js file using the function name just defined, and write a method to process the external JSON data;
4. Use the

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template