Right now, he contacts the server every time the user switches "Comments (X)"
I would like to do as soon as the user clicks .info.reply (comments (X)), the ajax loader will only appear until the data is complete and then the loader will disappear.
$('.info .reply').click( function() {
$('.reply', this.parentNode.parentNode).toggle();
return false;
});
$('.info .reply', this).mousedown( function() {
var id = $('form #id', this.parentNode.parentNode).val();
$.ajax({ url: location.href, type: 'post', data: 'id=' + id, dataType: 'json',
success: function(data) {
for (var i in data) {
}
}
});
return false;
});
What is the right way to do this?
Thank!
source
share