How can I get jQuery only once for ajax request?
Right now, he contacts the server every time the user switches "Comments (X)"
// Replies - Toggle display of comments $('.info .reply').click( function() { $('.reply', this.parentNode.parentNode).toggle(); return false; }); // Load comments $('.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) { // Do AJAX Updates } } }); return false; });
I think I can somehow put the unbind () event here after loading ajax data, but I'm not sure where!
Thank you for your help!
source share