SandaruwanH SandaruwanH - 5 months ago 8
Javascript Question

what are the advantages of done() method in $.ajax instead of success()

For example:

$.ajax({
url: '@Url.Action("_sampleMethod","Sample")',
type: 'GET',
cache: false,
}).done(function (result) {
// ...
});

Answer

done() method is helpful when there is a series of multiple Ajax calls and one waits on other to complete the callbacks. So that only after Ajax call A gets completed you execute your post Ajax code in done() . While success() is mainly a part of a single Ajax call that helps you process the response according to your needs .