Hello everyone, this is my first time really using this site. I'm relatively new to using ajax with my sites and I ran into a problem a little while ago. The thing is, I'm not sure what my problem is exactly because every time I went over my script, it made sense to me (and it fit with everything I looked up on Google and the jQuery website). Basically, my script doesn't work at all and I need to get it working somehow. If any of you could please help me, I would greatly appreciate it. Here's the code:
$(document).ready(function(){
$().ajaxSetup({cache: false});
setInterval("checkAnchor()", 300);
});
//Function which check if there are anchor changes, if there are, sends the ajax petition
var currentAnchor = null;
function checkAnchor() {
//Check if it has changed
if(currentAnchor != window.location.hash){
currentAnchor = window.location.hash;
var hash = window.location.hash.substr(1);
var newLink=$('a[href='+hash+']');
var toLoad = hash+'.html #content';
$('.current').removeClass('current');
newLink.addClass('current');
$('.box').slideUp(1500,function(){
//Send the petition
$('.box').load(toLoad,'');
});
$('#nav').append('<span id="load">LOADING...</span>');
$('#load').fadeIn('normal');
$('.box').slideDown(1500,function(){
$('#load').fadeOut('normal');
$('#load').remove();
});
});
}
And the html file:
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/general.css" />
</head>
<body>
<!--Nav Bar-->
<div id="nav" class="center round">
<ul>
<li><a class="current" href="#home">Home</a> | </li>
<li><a href="#upcomingevents">Upcoming Events</a> | </li>
<li><a href="#attractions">Attractions</a> | </li>
<li><a href="#facts">Facts</a> | </li>
<li><a href="#placestostay">Places to Stay</a> | </li>
<li><a href="#workscited">Works Cited</a></li>
</ul>
</div>
<!--This is where content is loaded via ajax-->
<div class="box center round">
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="scripts/ajax2.js"></script>
</body>
</html>