473,394 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

setInterval / setTimeout freezing browser?

57
Hi,
Has anyone seen this before? I have a "Now Playing" section for a radio station that displays what song is currently on the air. The on-air computer uploads an xml file with the song title, artist and album name. Then I use a javascript function that loads/displays the xml file and I've been using setInterval or setTimeout to have it update itself.

Here's the xml:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <audio>
  3. <title>Song Title</title>
  4. <artist>Artist</artist>
  5. <album_title>Album Title</album_title>
  6. </audio>
  7.  
Here's the javascript:
Expand|Select|Wrap|Line Numbers
  1. function nowPlaying() {
  2. xmlDoc = loadXMLDoc("xml/playlist.xml");
  3. title = xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue;
  4. artist = xmlDoc.getElementsByTagName("artist")[0].childNodes[0].nodeValue;
  5. album_title = xmlDoc.getElementsByTagName("album_title")[0].childNodes[0].nodeValue;
  6. document.getElementById("nowPlayingText").innerHTML = title + " by " + artist + "<br />From " + album_title;
  7. setTimeout("nowPlaying()",5000);
  8. }
  9.  
The problem is that the page will "freeze" for a few seconds...I can't click on anything, can't scroll the page...nothing, and then it goes back to normal. Is this glitch just the browser freezing while it loads the xml file? I've noticed it in FF, IE, Safari, Chrome and Opera and whether I'm using either setInterval or setTimeout. Is there maybe a way for the javascript to wait and load the xml file only after it changes?

Thanks in advance!
Jun 1 '10 #1
1 4460
Dormilich
8,658 Expert Mod 8TB
Is there maybe a way for the javascript to wait and load the xml file only after it changes?
due to the stateless nature of HTML, a website doesn’t know, when a server file changes.

however, you can do an AJAX HEAD request (similar to GET) and read the "Last-Modified" header. if that value changed, you have a new file.
Jun 1 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Robert Mark Bram | last post by:
Howdy All! I would like to find since when did different versions of browsers and/or JavaScript/JScript/ECMAScript support the SetTimeout and SetInterval methods.. this is for compatibility...
5
by: Richard A. DeVenezia | last post by:
Is some future Mozilla going to support setInterval ( <function:function>, <interval:number> ) ? Right now it seems to be simply setInterval ( <function-text:string>, <interval:number> ) --...
1
by: John | last post by:
Michael Winter <M.Winter@blueyonder.co.invalid> wrote in message news:<opr3wd8yvj5vklcq@news-text.blueyonder.co.uk>... > On 24 Feb 2004 14:13:47 -0800, John <johnmark@fastermail.com> wrote: > > >...
2
by: S.Hoitinga | last post by:
Hi, I am trying to create a header on a page that switches between 7 textitems in an array. using this code: <script language="JavaScript"> season=new...
18
by: Frances Del Rio | last post by:
this code is supposed to flip imgs at intervals of one second, but it flipps them much faster, it seems it flips them all in that first second, the more seconds the faster it flips them, instead of...
6
by: marktm | last post by:
Hi- I am trying to use setInterval to call a method within an object and have not had any luck. I get "Object doesn't support this property or method" when I execute the following code. What I...
1
by: James Black | last post by:
I am trying to fade a word out, so after 5 seconds then every 1/4 sec it should fade by a small amount, until it is gone. This works fine in Firefox, but IE never calls the function that...
4
by: E | last post by:
I am having trouble with setTimeout working on a second call to the setTimeout function from a second page which is an html page. Here is the scenario. I have a web page and onload it calls a...
15
by: nikki_herring | last post by:
I am using setTimeout( ) to continuously call a function that randomly rotates/displays 2 images on a page. The part I need help with is the second image should rotate 3 seconds after the first...
2
by: shawnwperkins | last post by:
Hi Folks, I'm new to Javascript and just need a little help. I downloaded a script from Dynamic Drive's Web site and I'm trying to make a simple modification and could use some help. :) The...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.