简体   繁体   中英

jQuery AJAX method and Post method

Is there any difference between $.post and $.ajax methods in jQuery

$.post("/SPA/Main/SaveEmployee", e).then({
    //code
});

and

$.ajax({
    url: "/Spa/SpaBulkUpload/Upload",
    type: 'POST',
    contentType: false,
    processData: false,
    data: fd
}).then(function (e) {
    //Code
});

The post method is a shorthand method for ajax with type of "POST" as stated in the jQuery documentation . But, you do still need to specify everything else except the type property.

$.post({
    url: "/Spa/SpaBulkUpload/Upload",
    contentType: false,
    processData: false,
    data: fd
}).then(function (e) {
    //Code
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM