ok, you need to add the select: event to your tab code. here's a quick example:
<div id="menu" style=" background-color:White; width:950px; height:400px; float:left;"> <div id="tabContainer"> <ul> <li><a href="#tab0">Home</a></li> <li><a href="#tab1">Products</a></li> <li><a href="#tab2">Contact Us</a></li> </ul> <div id="tab0"></div> <div id="tab1"></div> <div id="tab2"></div> </div> </div> <script> $(function() { var $tabs = $("#tabContainer").tabs({ select: function(e, ui) { var thistab = ui; runMethod(thistab.index); } }); }); function runMethod(thistab) { selectedtab = thistab; switch (thistab) { case 0: getTab0Data(); break; case 1: getTab1Data(); break; case 2: getTab2Data(); break; } } function getTab0Data(){ alert("you clicked Tab 0"); } function getTab1Data(){ alert("you clicked Tab 1"); } function getTab2Data(){ alert("you clicked Tab 2"); } </script>
[EDIT] I updated the example so that it starts. both jquery base lib and jQuery UI must be referenced on the page. I also added jsfiddle to demonstrate it in action: http://jsfiddle.net/jimibt/k7ZN6/
basically, the getTab * n * Data () function launches an ajax request that populates the corresponding div (i.e. tab0, tab1, tab2, etc.) in accordance with the above structure.
for jquery ajax see
http://api.jquery.com/jQuery.ajax/
hope this helps
source share