如何在 Bootstrap 选项卡中使用 AJAX 加载? [英] How to use AJAX loading with Bootstrap tabs?
本文介绍了如何在 Bootstrap 选项卡中使用 AJAX 加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用了 bootstrap-tabs.js,效果很好.
I used bootstrap-tabs.js and it has worked perfectly.
但是我没有找到关于如何通过 AJAX 请求加载内容的信息.
But I didn't find information about how to load content through AJAX request.
那么,如何在 bootstrap-tabs.js 中使用 AJAX 加载?
So, how to use AJAX loading with bootstrap-tabs.js?
推荐答案
可以监听change
事件和ajax在事件处理器中加载内容
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);
});
})
这篇关于如何在 Bootstrap 选项卡中使用 AJAX 加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文