jQuery(document).ready(function(){ $.ajax({ type: "get", url: "/script/ajax_check_login.php?ms=" + (new Date().getTime()) , dataType: "xml", error: function(msg){ }, success: function(xmlDocument){ if($(xmlDocument).find('yes').size() != 0){ change_the_link(); } } }); /* $.ajax */ }); /* .ready() */ function change_the_link(){ jQuery('a#login_link').each(function(){ $this = $(this); $(this).attr('href',$(this).attr('href').replace('login','logout')); $(this).text('Log Out'); }); }