jquery ui tab ajax 切换,默认选中第一个(序号为0)

来源:互联网 发布:怎样赢网络棋牌机器人 编辑:程序博客网 时间:2024/05/17 01:02
   <script>$(function() {var tabss = $('#tabs').tabs();//[object,object]var selectedTab = tabss.tabs('option', 'selected');if(0==selectedTab){ $.ajax({            url: "<%=basePath %>TopicSectionServlet.serv",            type: "post",            data: "key=" + name + "&doaction=check",            dataType: "json",            error:function(){            //dealFail();            alert('fail');            },            success: function (data) {            $("#atab2").html("成功-按部门1111");            }        });}$("#tabs").tabs({  select: function(event, ui) {  var name='5b92ed07-ba11-4d3d-bb6b-f642be25d46a';  var htmlStr = "";  if (ui.index == 0) {  $.ajax({            url: "<%=basePath %>TopicSectionServlet.serv",            type: "post",            data: "key=" + name + "&doaction=check",            dataType: "json",            error:function(){            //dealFail();            alert('fail');            },            success: function (data) {            $("#atab2").html("成功-按部门1111");            }        });  }  //  if (ui.index == 1) {  $.ajax({            url: "<%=basePath %>TopicSectionServlet.serv",            type: "post",            data: "key=" + name + "&doaction=check",            dataType: "json",            error:function(){            //dealFail();            alert('fail');            },            success: function (data) {            $("#btab2").html("成功-按部门2222");            }        });  }  //   if (ui.index == 2) {   $.ajax({            url: "<%=basePath %>TopicSectionServlet.serv",            type: "post",            data: "key=" + name + "&doaction=check",            dataType: "json",            error:function(){            //dealFail();            alert('fail');            },            success: function (data) {            $("#ctab2").html("成功-按部门3333");            }        });  }  //   if (ui.index == 3) {   $.ajax({            url: "<%=basePath %>TopicSectionServlet.serv",            type: "post",            data: "key=" + name + "&doaction=check",            dataType: "json",            error:function(){            //dealFail();            alert('fail');            },            success: function (data) {            $("#dtab2").html("成功-按部门4444");            }        });  }  //   if (ui.index == 4) {    $.ajax({            url: "<%=basePath %>TopicSectionServlet.serv",            type: "post",            data: "key=" + name + "&doaction=check",            dataType: "json",            error:function(){            //dealFail();            alert('fail');            },            success: function (data) {            $("#etab2").html("成功-按部门5555");            }        });  }  // }});});</script>


//
  if (ui.index == 1) {//加载版块数据  $.ajax({            url: "<%=basePath %>TopicServlet.serv",            type: "post",            data: "key=" + name + "&doaction=statisticsBySectionId",            dataType: "json",            error:function(){            alert('数据加载失败!');            },            success: function (data) {             var len=data.length;              //所有版块         $('#sectionName-s').contents().remove();           $('<option >请选择</option>').appendTo('#sectionName-s');          for(i=0;i<len;i++){          $("#sectionName-s").append($('<option value='+data[i].tsb.id+'>'+data[i].tsb.sectionName+'</option>'));         }          //所有数据            $("#btab2").html("成功-按部门2222");            }        });  }
0 0