Data interaction Notes

Source: Internet
Author: User

1. When simulating JSON data, be aware that:

A> property name with double quotation marks

b> when referencing data, use the $.each (data, function (Index,val) {}) when using $.parsejson (data) c> to iterate over data;

2. Define the data if it is a list of the same set of functions, you can use the array method, for example [{},{},{}]

Define the data if there is a combination of different functions (such as the following code) {"A": 1111, "B": 2222, "C": [{},{},{}]}

3.a>$.ajax requests HTTP XML, which can be used when synchronizing (waiting for data to be loaded and then executing code) async:false

b> when the data format is JSONP, the data is requested through <script>, if you want to synchronize to execute the code in a successful callback.

DataType to be set to JSONP when c> data exists across domains

1 varAAA ={2Init:function(){3         varSelf = This;4Self.getdata (function(){5             //execute the relevant code after the data has been loaded6         });7     },8GetData:function(callback) {9         varSelf = This;Ten $.ajax ({ OneType: ' GET ', AURL: ", -DataType: ' Jsonp ', -Asyncfalse, theSuccessfunction(data) { - callback (); -             } -     } +}

/**** ******** * * Data Format example ****** ******** ****/

1 {2 " coverpic": "Http://123.103.23.79/wyw/calendar/images/cover-top.png",3 " monthpic": "Http://123.103.23.79/wyw/calendar/images/month-img.png",4 "inner": [{5 "type": "Cate",6 " spic": "Http://123.103.23.79/wyw/calendar/images/img01.jpg",7 " bpic": "Http://123.103.23.79/wyw/calendar/images/img01.jpg",8 "date": "2014-11-14",9 " title": "Shopping 1 don't eat sushi. Japan has something more tasty",Ten " desc": "Don't eat sushi. Japan has something better to eat than sushi. There's more to eat in Japan than sushi. Japan has something better to eat than sushi. Japan has better food. One     },{ A "type": "Sense", - " spic": "Http://123.103.23.79/wyw/calendar/images/img04.jpg", - " bpic": "Http://123.103.23.79/wyw/calendar/images/img001.jpg", the "date": "2014-11-15", - " title": "Shopping 1 don't eat sushi. Japan has something more tasty", - " desc": "Don't eat sushi. Japan has something better to eat than sushi. There's more to eat in Japan than sushi. Japan has something better to eat than sushi. Japan has better food. -     },{ + "type": "Event", - " spic": "Http://123.103.23.79/wyw/calendar/images/img02.jpg", + " bpic": "Http://123.103.23.79/wyw/calendar/images/img02.jpg", A "date": "2014-11-16", at " title": "Shopping 1 don't eat sushi. Japan has something more tasty", - " desc": "Don't eat sushi. Japan has something better to eat than sushi. There's more to eat in Japan than sushi. Japan has something better to eat than sushi. Japan has better food. -     }] -}

Data interaction Notes

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.