Online Forum To Support Coders With Technical Assistance - Read Write Execute

Jquery mCustomScrollbar not working with ajax

Ankit Agrawal
Ankit Agrawal
Published on May 3, 2018 · 1 min read

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();
        }
    });
});

Was this article helpful?
Ankit Agrawal

Ankit Agrawal

Author & Senior Engineer at CodeExecute

Writing practical engineering guides, debugging real-world bottlenecks, and creating free tools for developer productivity.

← Previous Article What is web framework Next Article → Remove public from url in laravel