Request ajax per button jquery, twitter bootstrap -


how ajax response clicked button?

the html part:

<button type="button" class="btn btn-success ccomment" rel="popover" data-original-title="comment" value="12">click</button> <button type="button" class="btn btn-success ccomment" rel="popover" data-original-title="comment" value="460">click</button> 

and jquery script:

<script type='text/javascript' language='javascript'> $('.ccomment').click(function(){      var ccomment_val = $(this).val();      $.ajax({         url: '/getcomment/'+ccomment_val,         type:'post',         datatype: 'json',         success: function(output){              $('.ccomment').popover({                 content: output,                 html: true,                 placement: 'right',                 trigger: 'click'             });         }      });     });  </script> 

i want bind valid ajax response specific button. right now, output related button clicked first.

thank you

not 100% sure trying achieve explanation isn't great. have spotted believe potential issue in script, assuming think does. here's solution (i hope).

underneath line var ccoment_val.... add:

var self = $(this);

this add reference clicked button can use in ajax response. once have added line, change: $('.ccomment').popover( in ajax success function to: self.popover(

that should solve think trying problem, if not, apologise.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -