Basic jQuery AJAX performance Inquiry
When doing ajax requests using jQuery's ajax() function I never use any parameters other than "data" in the success callback:
$.ajax({
url: 'script.php',
type: 'post',
data: $(this).serialize(),
dataType: 'json',
success: function(data) {
alert(data);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
}
});
But I was wondering if keeping the other 2 parameters (textStatus, jqXHR) in that function will have any performance impact:
success: function(data, textStatus, jqXHR) {
alert(data);
}
I am not doing anything 开发者_运维技巧with "textStatus" and "jqXHR", but if I kept them there will there be any performance decrease (even a little)?
Maybe a little bit, but nothing noticeable considering you're not referencing them - no memory lookups will have to be performed.
If you're doing millions of AJAX calls a second, you might see a delay, but how on Earth you can do a million AJAX requests a second I don't know.
精彩评论