日期:2014-05-16  浏览次数:20833 次

jquery ui tab ajax 切换,默认选中第一个(序号为0)
   <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