javascript - .html not working with live() Jquery -


i'm trying use method live , works intended, ajax 'success' callback not functioning correctly on subsequent runs of function.

$(function () {     $('.vote').live('click', function () {         url = '".base_url()."post/vote';         post_id = $(this).attr('id');          $.ajax({             url: url,             type: 'post',             data: 'post_id=' + post_id,             success: function (msg) {                 post = $('.num_vote' + post_id);                 vote = $('.votes' + post_id);                 $(vote).html(msg); // working first time             }         });         return false;     }); }); 

depending on version of jquery using, may need use .on function .live() deprecated in 1.7 , removed in 1.9.

$(function(){     $('.vote').on( 'click', function() {             url = '".base_url()."post/vote';             post_id = $(this).attr('id');             $.ajax({                     url: url,                     type: 'post',                     data: 'post_id=' + post_id,                     success: function(msg) {                                                     post = $('.num_vote' + post_id);                         vote = $('.votes' + post_id);                             $(vote).html(msg); // working first time                      }             });             return false;     }); }); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -