BladeRunner's avatar

Updating DOM after AJAX inserts updated element

I have the following ajax call:

    $("#searchField").on('keyup', function(){
             var value = $(this).val();
              $.ajax({
                type : 'get',
                url : 'livesearch',
                data : {
                    search:value

                },
                success : function(data){
                  console.log(data);
                  $('#myDiv').html(data);
                }

              });

      });

It updates the myDiv element but DOM does not change.

How do I update the DOM?

0 likes
4 replies
JeffreyWay's avatar

I'm not sure what you mean. If it correctly updates the #myDiv element, then the DOM has been updated.

BladeRunner's avatar

Ok, maybe I have not properly asked a question.

Within myDiv I have labels which are clickable and then something happens as a result of jQuery attached to that click.

After myDiv is updated this does not work.

Please or to participate in this conversation.