Reload javascript file after an AJAX request

前端 未结 10 724
粉色の甜心
粉色の甜心 2020-12-13 20:25

After the request, the new elements created are not recognized by the event handlers in my jQuery code.

Is there a way to reload the file to re-register these events

10条回答
  •  星月不相逢
    2020-12-13 21:01

    In your request callback, call a function that acts on your newly appended or created blocks.

    $.ajax({
       success: function(data) {
            $('body').append(data);
            //do your javascript here to act on new blocks
       }
    });
    

提交回复
热议问题