javascript - Ajax post with on() -


$('body').on('click','.removebet i',function(e){     var = $(this).attr("id");     var data = "a="+a;      $.ajax({         type: "post",         url: "yorumcikar.php",         data: data,         success: function(e){     }); 

i'll explain problem. can post ajax form function , there's no problem except .removebet i comes ajax.

if append .removebet i ajax function doesn't work because doesn't call ajax.

example:

$(".maindiv").html("<span class='removebet'><i>yes</i></span>"); 

then when clicked 'i' tag function @ top doesn't work.

i believe should work.

$('.removebet > i').click(function(event){     var = $(this).attr("id");     alert(a);      $.ajax({         type: "post",         url: "yorumcikar.php",         data: data,         success: function(retval){             alert(retval);         }     }); }); 

edit

this work, each newly added item not bound binding has happened. in order newly added items bound have rebind them when added.

$.ajax({call new item},       success: function(data){           // add dom           bindelement(newelement);       }  });  function bindelement(element){ $(element).click(function(event){     var = $(this).attr("id");     alert(a);      $.ajax({         type: "post",         url: "yorumcikar.php",         data: data,         success: function(retval){             alert(retval);         }     }); }); } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -