Summary of usage of $.get (), $.post (), $.ajax (), $.getjson () in jquery

Source: Internet
Author: User

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

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.