Monday, 9 September 2013

executing jquery .load() twice in a row

executing jquery .load() twice in a row

So here is what I am trying to get done. I am trying to make 2 files load
into 2 separate divs at the same time
Here is the code for the Jquery
links.js
$(document).ready(function() {
$('#content').load($('.nav2:first').attr('href'));
});
$('.nav2').click(function() {
var href = $(this).attr('href');
switch (href){
case "home.php":
$('#content').hide() .load(href) .fadeIn('normal');
break;
case "crm.php":
$('#content').hide() .load(href) .fadeIn('normal');
$('#nav3').hide() .load(crm_nav.php) .fadeIn('normal');
break;
case "inventory.php":
$('#content').hide() .load(href) .fadeIn('normal');
$('#nav3').hide() .load(inventory_nav.php) .fadeIn('normal');
break;
case "sales.php":
$('#content').hide() .load(href) .fadeIn('normal');
$('#nav3').hide() .load(sales_nav.php) .fadeIn('normal');
break;
case "listings.php":
$('#content').hide() .load(href) .fadeIn('normal');
$('#nav3').hide() .load(listings_nav.php) .fadeIn('normal');
break;
case "users.php":
$('#content').hide() .load(href) .fadeIn('normal');
$('#nav3').hide() .load(users_nav.php) .fadeIn('normal');
break;
default:
}
return false;
});
index.php
<!DOCTYPE html>
<?php
include 'AUTH/db_connect.php';
include 'AUTH/functions.php';
sec_session_start();
?>
<html>
<head>
<link href="css/index.css" rel="stylesheet" type="text/css">
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="author" content="Corey David Herrera" />
<title>Laptop Parts</title>
</head>
<body>
<div id="page-container">
<div id="main-nav">
<?php
include("nav/nav1.html");
?>
<h1><a href="index.php"><img src="Logo/logo1.png" width="100"
height="50" alt="Return to the Ancient Paths" border="0" /></a></h1>
</div>
<div id="nav3"></div>
<?php
include '../AUTH/db_connect.php';
include '../AUTH/functions.php';
sec_session_start();
if(login_check($mysqli) == true) {
echo '<div id="sidebar-auth" class="nav2">';
} else {
echo '<div id="sidebar-anon">';
}
?>
<div class="padding">
<?php
include("nav/nav2.php");
?>
</div>
</div>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/links.js"></script>
<div id="content"></div>
<div id="footer">
<div id="altnav">
<?php
include("nav/footer.php");
?>
</div>
Copyright &copy; Global Technology Restoration Services Corp
</div>
</div>
</body>
</html>
The first execution loads as desired but the second causes nav3 to
disappear. I am failing to see the issue with my code. Any suggestions?

No comments:

Post a Comment