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