I am using the jquery tab plugin by Jlaus and it works fine. Now instead of
writing content that appears in the tabs in divs, I am trying to get the
content in each tab with Ajax. The link for the file to fetch by Ajax from
the server is provided as a variable form the php code along with another
variable that defines the div id to update.
This is what I have writtten but it does not work...
in head I have this code
$(document).ready(function() {
$('#container').tabs({fxAutoHeight: true});
hitab();
});
function hitab(tabid,tabcon){
var url = tabcon.split('/');
var link=(url[url.length-1]);
var linkid=(link.replace(/index/, "index2"));
$(tabid).load(linkid);
}
the php code (simplified) is like this
$tabscontents = explode("#", $htmllinks);
echo "<div id=\"container\">\n";
echo "<ul class=\"anchors\">\n";
$tabsnamea = explode(",", $tabsname);
$k=0;
foreach ($tabsnamea as $tabsname){
echo"<li>a class=\"tabid\" href=\"javascript:void(0)\"
onclick=\"hitab('section-$k','$tabscontents[$k]')\">Section
$k</a</li>\n";(removed < and > to avoid converting it into a link)
$k=$k+1;
}
echo "</ul>\n";
$tabscontents = explode("#", $htmllinks);
$i=0;
foreach ($tabscontents as $htmllink){
echo "<div id=\"section-$i\" class=\"fragment\">\n";
$htmlcont = '<h3>Section'.$i.'</h3>
<p>'.$htmllink.'</p>';
echo $htmlcont;
echo "</div>\n";
$i=$i+1;
}
echo "</div>";
Although it will update the first tab but when I click the second tab it
says the
$(tabid).load(linkid); is not a function. Whichever tab I click first, that
tab is updated but any other tab I click throws this error. I have spent two
days on it trying every possibility but to no magic. I am using jquery
version1.1 and latest version of jquery tab.
I need help from jquery community. I am a surgeon by profession and coding
is just a hobby for me and I love this hobby. So my code may be very stupid
but this is all I have learnt by reading on internet.
I appreciate any help in advance.
thanks
vik
--
View this message in context:
http://www.nabble.com/need-to-show-content-by-ajax-in-tabs-tf3062411.html#a8515811
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/