Hi, and thanks for your previous help.
I have a function which is triggered when users click on a menu item in the main menu. It check whether the href attribute for the menu item is set (if not it will return true) and if it is, will make an ajax request. The returned data will be checked for the string, "session-timeout" and if present, the user is redirected to the index page. If not present, the old content will be faded out and the new faded in.
At least that's how it's supposed to work in theory. In practice, I can't get the "session-timeout" to trigger the redirection because I can't get the if statement to work properly.
Here's the code:
- $('#nav li a').click(function(e) {
// Figure out which method to use, this one or the original?
$('#nav li').children('ul').stop().slideUp(300);
var h = $(this).attr('href');
if (h.length > 1){
e.preventDefault();
$.get( h, function(data) {
if (data.indexOf('session-timeout')) {
// timeout received, so redirect to login.
window.location="index.php";
exit;
} else {
$('#contentMAIN').fadeOut(500,function() {
$(this).html(data).fadeIn(500);
});
}
});
// var thisURL = location.href;
// if( thisURL.indexOf('<search-page-url.html>') ) { myQuote.hide(); }
// Prevent the hyperlink from activating in the traditional way
return false ;
} else {
// Return and allow other actions to be activated
return true;
}
});
});
Perhaps someone would be kind enough to tell me where I'm going wrong please?
Kind regards,
Peter
A Linux Admin
Willing to help maintain Linux servers remotely for a tiny consideration into my Paypal account :-)