What is the jsonp protocol? Differences between json and jsonp

Source: Internet
Author: User
1. json is a simple data description format. The symbols used contain a set of unordered key-value pairs of different types. braces {} & amp; nbsp; brackets [] & amp; nbsp; ing character Colon: & amp; nbsp; double quotation marks & quot; & amp; nb

1. json is just a simple data description format. The symbols used contain a set of unordered key-value pairs of different types. The set braces {} are a set of identical sorted set square brackets [] ing characters Colon: the double quotation mark "" delimiter comma, as shown in the following example:

/* From Network * // describe a person var person = {"Name": "Bob", "Age": 32, "Company": "IBM", "Engineer ": true} // obtain the information of this person var personAge = person. age; // describe several people var members = [{"Name": "Bob", "Age": 32, "Company": "IBM", "Engineer ": true },{ "Name": "John", "Age": 20, "Company": "Oracle", "Engineer": false },{ "Name ": "Henry", "Age": 45, "Company": "Microsoft", "Engineer ": false}] // read the company name var johnsCompany = members [1]. company; // describe a meeting var conference = {"Conference": "Future Marketing", "Date": "2012-6-1", "Address": "Beijing", "Members ": [{"Name": "Bob", "Age": 32, "Company": "IBM", "Engineer": true}, {"Name": "John ", "Age": 20, "Company": "Oracle", "Engineer": false },{ "Name": "Henry", "Age": 45, "Company ": "Microsoft", "Engineer": false}]} // reads whether the participant Henry is an Engineer var henryIsAnEngineer = conference. members [2]. engineer;

2. jsonp is totally different from this. As we all know, Ajax cannot carry out cross-request, but remote cross-origin request files are acceptable, such as scripts to request remote files, in this way, the remote server can load the data into the js format file for the client to call. Because the json format is simple and clear, and the client can process the data conveniently, JSONP is an unofficial protocol that allows the server to integrate Script tags to return to the client, cross-origin access is implemented through javascript callback (this is only a simple implementation form of JSONP ). This Protocol is characterized by the client passing a callback function to the server to process json data. As follows:
 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.