I am using jQuery version jquery-1.8.2.js and jquery-ui.js v1.9.0. I have a php page with index.php. it loads fine when I open index.php but when I switch tab the content take time in loading I have viewed the details from firebug jquery-1.8.2.js took 4.84 seconds and jquery-ui took 8.32 seconds and the ajax call took659ms. It seems that jquery is taking enough time in loading and I am unable to find the reason I have the following code in index.php
$(function() {
$( "#tabs" ).tabs({
beforeLoad: function( event, ui ) {
ui.jqXHR.error(function() {
ui.panel.html(
"Couldn't load this tab." );
});
}
});
});
<div id="tabs">
<ul>
<li><a href="#tabs-1">Set Up</a></li>
<li><a href="temp1.php">temp1 </a></li>
<li><a href="temp2.php">temp 2</a></li>
<li><a href="temp3.php">temp 3</a></li>
</ul>
<div id="tabs-1">
content here
</div>
</div>
and in temp1.php I have one ajax method which is filling data in a table.
Although I am not totally sure you are asking, the last sentence is leading me to believe you are not sure why you need the JavaScript code below:
$(function() {
$( "#tabs" ).tabs({
beforeLoad: function( event, ui ) {
ui.jqXHR.error(function() {
ui.panel.html(
"Couldn't load this tab." );
});
}
});
});
The reason this code is there is because it is an error handler for anything going on in the div with the ID of "tabs". So, if you go to load something and there is an error returned, that handler will catch the error and display the nice text of "Couldn't load this tab." instead of seeing nothing. The reason the error handler is placed on beforeLoad
is because the primary place errors come from when using tabs happen DURING loading - so if the handler isn't placed before the error potentially happens - it can't be caught.
ok i am here to answer my own question, i noticed i had the link to jquery-ui.css and jquery.js in head section of my all pages e.g. temp1.php,temp2.php and temp3.php which are define in ul on index.php as part of tab. after removing them it works fine. i believe the js and css was loading on each page which shouldn't in case of tab pages because it is loaded on index.php