How do I execute a javascript after Ajax load?

后端 未结 2 1725
梦谈多话
梦谈多话 2021-01-18 09:17

I need to add a class on after an ajax load. I first give a few elements a class \"ready\" which initiate a css transition. When the link li#menu-item-318 a gets clicked it

2条回答
  •  温柔的废话
    2021-01-18 10:17

    You can use ajaxComplete():

    $.ajaxComplete(function () {
      // Something to execute after AJAX.
    });
    

    Have this as an example:

    $( document ).ajaxComplete(function( event,request, settings ) {
      $( "#msg" ).append( "
  • Request Complete.
  • " ); });

    As said by Popnoodles, this executes when any AJAX call completes. So if you are looking for executing the code in one particular AJAX call, you need to use the success function.

提交回复
热议问题