在不刷新页面的情况下,可以使用哪些技术更新包含更新内容的网页? [关闭]

We have been offered training at work for courses on what ever we want. What we are trying to achieve is the following: we have a page with stats from multiple folders/servers (we can deliver these in any format, html, txt etc). Currently it refreshes every minute with the up to date info. What we want is for the page not to refresh, but just the data within the page to change when it changes elsewhere, we want this to update when it happens (if possible) rather than every minute. An example I'd give is Facebook or Twitter updating the feed when someone posts something new

What technologies would we require for this to work? jquery? ajax? javascript? and is there a specific part of the technology that would do this that we can target the course to be about?

Any help/pointers appreciated

You're looking for Push technology.

The slightly dated way of simulating this is "long-polling" or Comet where (essentially) an AJAX request remains open for a long period of time (instead of constantly polling), until the server actually has a response to send.

Nowadays, you should look into websockets or a commercial product like like pusher which uses websockets to initiate communication server-side, rather than constantly polling from the client.

You can either do polling with AJAX, with a short interval, or use websockets with Node.js or something similar.

Read more about Node.js here: http://nodejs.org/

You must be already using a server side programming language like PHP, Java, ASP etc to fetch list of files from a directory and show on the webpage.

As you want to refresh data, without reloading the webpage, you have to rely on AJAX. AJAX is a browser (or client) side technology, which is independent of the server side technology you use. AJAX allows you to call the same server side script from Javascript without reloading the page (happens silently). After that using the response received from the AJAX call you can re-populate/refresh your web page with latest data using Javascript.

jQuery is a Javascript framework which provides number of AJAX APIs. These APIs make your Javascript code (for making the ajax call) shorter and thus your work becomes easier.

Learn AJAX from W3Schools, which is one of the best tutorial sites for beginners.