473,396 Members | 1,671 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,396 software developers and data experts.

Refresh Javascript RSS Feed without flickering

1
Hello,

I have the following RSS feed: RSS Feed
I load this feed like this:
file: rss2.php
Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <link rel="stylesheet" type="text/css" href="rss.css" media="screen" />
  3. </head>
  4. <body style="margin: 0px;">
  5.  
  6. <div id="RSS_Feed">
  7. <script language="JavaScript" src="http://rss.nuvini.com/list/feed2js/feed2js.php?src=http%3A%2F%2Frss.nuvini.com%2Fpublic.php%3Fop%3Drss%26id%3D-1027%26key%3D19a8dbb063bf0c30d5e74c5fb619f33255a027db&num=15&tz=+2&targ=y&utf=y"  charset="UTF-8" type="text/javascript"></script>
  8. </div>
  9. </body>
Now what I want to do, is automatically refresh this page. I tried to do this with a meta tag, but this gives flickering when it refreshes.

Now what I want to do, is check for updates in the RSS feed, say, every 1 minute. If there are updates, I want it to display the latest feed, but I don't want it to flicker.
I understood that the way to do this is through javascript/jquery/AJAX. My knowledge of those is pretty much nonexistant, so I googled quite a bit and found some tutorials and such, but nothing seems to work the way I want for me. In the end I think at some point I had something that did refresh fine but it didn't load the CSS so I was missing the layout.

Besides the rss2 file I also have rss-testing.php, this is what I have right now whilst trying, but it's not working at all for me:
Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <link rel="stylesheet" type="text/css" href="rss.css" media="screen" />
  3. <script language="javascript">
  4. function loadPageContents() {
  5.   var AJAX = XMLHTTPRequest();
  6.   AJAX.open('GET','rss2.php',true);
  7.   AJAX.onreadystatechange = function() {
  8.     if(this.readyState==4 && this.responseText) {
  9.       document.getElementById('RSS_Feed').innerHTML = this.responseText;
  10.       loadingPage = setTimeout('loadPageContents()',5000);
  11.     }
  12.   }
  13.   AJAX.send(null);
  14. }
  15. </script>
  16. </head>
  17.  
  18. <body style="margin: 0px;">
  19. <script language="JavaScript">
  20. window.onload = function () {
  21.         var loadingPage = setTimeout('loadPageContents()',5000);
  22. }
  23.  
  24. <div id="RSS_Feed">
  25. </div>
  26.  
  27.  
  28.  
  29.  
  30. </body>
If anyone knows how to achieve this, that would be awesome.

If it helps, this is the code that did some refreshing without flickering (that I could see) but it missed the CSS.
Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <link rel="stylesheet" type="text/css" href="rss.css" media="screen" />
  3. <script language="javascript" src="js/jquery-2.0.1.min.js"></script>
  4. </head>
  5.  
  6. <body style="margin: 0px;">
  7.  
  8. <script language="javascript">
  9. $(function() {
  10.     startRefresh();
  11. });
  12.  
  13. function startRefresh() {
  14.     setTimeout(startRefresh,5000);
  15.     $.get('rss2.php', function(data) {
  16.     $('#RSS_Feed').html(data);
  17.     });
  18. }
  19. </script>
  20. <div id="RSS_Feed">
  21. </div>
  22.  
  23.  
  24.  
  25.  
  26. </body>
  27.  
Thanks!
Jun 7 '13 #1
1 2316
gits
5,390 Expert Mod 4TB
in line 5 of your non-working example it has to be:

Expand|Select|Wrap|Line Numbers
  1. var AJAX = new XMLHttpRequest;
at least. if u want to support older IEs then you need to use IE's activeX objects here like: http://en.wikipedia.org/wiki/XMLHttpRequest
Jun 10 '13 #2

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

Similar topics

0
by: Stewart Midwinter | last post by:
I've got a Tkinter app that draws three histograms. At this point I am simulating real data by drawing rectangles whose size is defined by random numbers; in the future there would be real data...
2
by: Neo | last post by:
can anybody help me in writing a javascript function which opens a popup window with the target URL when the link "POST Request" is clicked.. Points to note: The HTML DOESNT and SHOULDNT...
3
by: Troy | last post by:
Hello- I have a website that uses a custom built webserver to serve the pages. (Please don't ask me why my boss had his own web server written). I am displaying a log of information that is an...
8
by: Dan | last post by:
hello all, is there a way to open a new window without javascript and a href=_blank? i need to connect a button click with some lines of code and then, a new window shall get opened. but i didn't...
5
by: JamesBond | last post by:
I am using a javascript in my html page which will be updated daily. However, the javascript is getting cached by the browser and whenever the user visits my html page, he is getting a cached copy...
3
by: Jason James | last post by:
Hi all, my asp.net hoster does not provide me with access to the system.io library, so using a stringwriter as the output stream to write the XML needed for my RSS feed is looking very...
7
by: ponvijaya | last post by:
Hi All, I have one requirement... Its like a search engine design. I will have a text box to type in the search text and a search button on clicking which the search action should take...
1
by: Polaris | last post by:
Hi Experts: My program (Windows Form with C# and .net 2.0) shows a bitmap (a bitmap file selected by the user) and allows the user to drag it to different positions within the client area. I use...
9
by: Denis | last post by:
Hello, Maybe somebody already solved this task. I need to load JS asynchronously without blocking browser. This means that I do not need to block browser to load/render during loading script. The...
2
by: sajankonni | last post by:
i want to refresh image buttons in asp.net,only without reloading the entire page.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.