Jquery mCustomScrollbar not working with ajax | Codeexecute

Jquery mCustomScrollbar not working with ajax

mCustomScrollbar directly not working with ajax we have to initialize it again while using ajax. Please use following code


jQuery(document).ready(function(){
    jQuery(".your ajax content div").mCustomScrollbar();

    jQuery.ajax({
        url: "your ajax url",
        type: "post",
        data: "your post data",
        success: function(response) {
            jQuery(".your ajax content div").mCustomScrollbar("destroy"); //First we have to destroy
            jQuery(".your ajax content div").html(response);
        },
        complete: function () {
            jQuery(".your ajax content div").mCustomScrollbar();
        }
    });
});