Reputation: 11
I am trying to dynamically update the document title from php script in regular intervals, it seems to not be working. I am a beginner to jquery, please help.
<div id="code" style="border: 1px solid; "></div>
<script>
var blink = true;
setInterval(function(){
if(blink){
jQuery('#code').load('test.php', function(result) {
var theTitle = document.getElementsByTagName("title")[0];
theTitle= 'google'+jQuery('#code').html();
});
//theTitle.text =document.getElementById('code').value;
blink = false;
}else{
jQuery('#code').load('test.php', function(result) {
var theTitle = document.getElementsByTagName("title")[0];
theTitle= 'yahoo'+jQuery('#code').html();
});
blink = true;
}
}, 2000);
Upvotes: 1
Views: 74
Reputation: 1631
if you use jquery try this:
var blink = true;
setInterval(function(){
$('#code').load('test.php', function(result) {
$('title').text(blink ? 'google'+$('#code').html() : 'yahoo'+$('#code').html());
blink = !blink;
});
}, 2000);
Upvotes: 0