最佳答案
Which one should I use?
Is there any reason to use one rather than the other?
Is one better for error handling?
$.ajax({
url: url,
data: { start: start, end: end }
}).done(function(data, textStatus, jqXHR) {
$('#myElement').append(data);
}).fail(function() {
// report error
});
OR
$.ajax({
url: url,
data: { start: start, end: end },
success: function(data, textStatus, jqXHR) {
$('#myElement').append(data);
},
error: function(jqXHR, textStatus, errorThrown) {
// report error
}
});