Summarize:
1.$.get $.post are used Similarly, are default asynchronous requests. $.get (Url,[data],[callback]),$.post (Url,[data],[callback],[type]), type is the requested data type, can be Html,xml,json, and so on , if we set this parameter to: JSON, then the returned format is in JSON format, and if it is not set, it is the same as the format returned by $.get (), which is the string
$.get ("url", function (data) {
var data = json.parse (data), result = Data.result;
Console.log (data);
})
var postdata = {
"Schoolguid": Schoolguid,
"Subjectname": Subjectname,
"Coursename": Coursename,
"Voicebroadcastcode": Voicebroadcastcode,
"Voicebroadcastdesc": Voicebroadcastdesc
};
$.post (window.web.host + "Voicebroadcast/voicebroadcastbatchcreate", PostData, function (data) {
var data = json.parse (data);
2. Ajax synchronization Requests
Async:false synchronization request, note that the synchronization request will lock the browser, the user other operations must wait for the request to complete before they can execute
$.ajax ({
URL: ' Https://pcs.baidu.com/rest/2.0/pcs/device ',
Async:false,
Type: "Get",
Data: {
Method: "VOD",
Shareid:shareid,
Uk:uk,
St:startstamp,
Et:endstamp
},
Success:function (data) {
$ ("#video"). attr ("src", data["src"]);
},
Error:function (XMLHttpRequest, Textstatus, Errthrown) {
Tip ("Get Video playback address failed");
}
})
Summary of usage of $.get (), $.post (), $.ajax (), $.getjson () in jquery