gpt4 book ai didi

php - onclick 选项卡时发生不同的事件

转载 作者:行者123 更新时间:2023-11-30 23:51:16 24 4
gpt4 key购买 nike

我已经通过 jquery 创建了一个选项卡,我想在每个选项卡上显示数据库中的不同数据,知道它是相同的容器和相同的数据但具有不同的条件,我该如何做到这一点希望很快找到答案我正在使用 php 和 javascript谢谢

最佳答案

我会创建一个选项卡 ID 到单击选项卡时要调用的远程 URL 的映射。例如,在 JS 中:

<script type="text/javascript">
var mySources = [];
mySources['home'] = '/ajax/getHome.php';
mySources['about'] = '/ajax/getAbout.php';
</script>

而且,当构建页面时,可以轻松添加点击监听器和 ajax 调用:

$(function(){
$("#myTabContainer a.tabLink").click(function(event){
event.preventDefault();
url = mySources[this.id];
$.get(url,null,
function(data){
// this is the data returned by the server,
// put it wherever it needs to go
}
);
});
});

只是我的 0.02 美元,但这至少是我开始的方式。祝你好运!

关于php - onclick 选项卡时发生不同的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1477403/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com