As an exercise, I'm trying to make my links in the navbar contract the content div, load the page in #content using ajaxpage() and then slide it back down. I'm using the following:
EDIT: I realized that I probably needed everything in a callback function, so I fixed that. The call still isn't working, though.
$(document).ready(function()
{
$("a.link").click(function() {
//...
return false;
});
$("#navbar a").click(function(){
$("#content").slideUp(500,function(){
var a_href = $(this).attr('href');
ajaxpage(a_href, 'content');
$("#content").slideDown(500);
});
});
});
With the link being:
<a class="link" href="home.php">Home</a>
When I test it, the content div correctly slides up, but then it stays there and nothing else happens. What did I do wrong here?
EDIT: After some debugging, it seems like this is the culprit:
var a_href = $(this).attr('href');
When I declare that variable and send it through an alert(), it says "undefined". I'm guessing I'm not grabbing the attribute properly, so this is where it's hanging up! How would I properly go about grabbing the href attribute of the link that you click?
ajaxpagefunction. I can also tell you the call is probably asynchronous, so yourslideDownshould be in the AJAX callback.