How to use AJAX loading with Bootstrap tabs?

后端 未结 10 1634
無奈伤痛
無奈伤痛 2020-12-02 08:30

I used bootstrap-tabs.js and it has worked perfectly.

But I didn\'t find information about how to load content through AJAX request.

So, how to use AJAX load

10条回答
  •  执念已碎
    2020-12-02 09:06

    You can listen the change event and ajax load content in the event handler

    $('.tabs').bind('change', function (e) {
        var now_tab = e.target // activated tab
    
        // get the div's id
        var divid = $(now_tab).attr('href').substr(1);
    
        $.getJSON('xxx.php').success(function(data){
            $("#"+divid).text(data.msg);
        });
    })
    

提交回复
热议问题