php - Looks like javascript doesn't recognize new elements after ajax call -


i got element loads data in according block clicked.

using ajax load entire phpfile inside index after variable sent it.

for example:

block 1 clicked, $block (containing string: block1) sent php script place $block in query retrieve correct data. after load result on index.

this works should javascript functionalities broken. when add php script in index , don't retrieve using ajax add word manually (where $block be) javascript works fine.

so seems when result loaded, javascript finished or doesn't recognize it. how can fix that?

my code retrieve it:

$('.handmouse').on('click', function(e){         var alias = $(this).attr("data-attribute");         var clicked = true;         $.post("ajax/blokken.php", {           dienstnaam : alias         }, function(data) {             $(".tabwrapper").html(data);         });         $('.tabwrapper').slidetoggle();         if(clicked != true){           $('html, body').animate({               scrolltop: $(".tabwrapper").offset().top           }, 2000);         }     }); 

you need put code success method of ajax call , not after ajax call, because ajax call async.

$('.handmouse').on('click', function(e){         var alias = $(this).attr("data-attribute");         var clicked = true;         $.post("ajax/blokken.php", {           dienstnaam : alias         }, function(data) {             $(".tabwrapper").html(data);             $('.tabwrapper').slidetoggle();             if(clicked != true){               $('html, body').animate({                   scrolltop: $(".tabwrapper").offset().top               }, 2000);             }         });     }); 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -