Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Group info
Members: 22
Language: English
Group categories:
Computers > Databases
Computers > Programming
Computers
More group info »
Recent pages and files
polling-the-server-with-ajax    

If you?ve been reading the series of articles about the Ajax approachto building Web applications, here?s another! In this article, I?mgoing to show you how to poll the Web server at regular intervals withthe XMLHttpRequest object. In other words, we?ll use an Ajax approachto request information from the server and load it into a Webinterface. Then we?ll refresh the data regularly, so you can seeupdates.

If you haven?t been following the articles, Ajax is a Web 2.0 approachto building Web applications. It allows you to load data from theserver asynchronously by using JavaScript and the XMLHttpRequestobject. Asynchronous means that the loading takes place in thebackground so that the user can carry on working with the Webapplication.

In this tutorial, we?ll load a simple RSS 2.0 feed containing usefullinks into a Web page. We?ll update the list regularly using thesetInterval command in JavaScript. We?ll also address the topic ofmulti-dimensional arrays in JavaScript. If you want to find out moreabout the RSS 2.0 specification and the XML tags that are used, checkout http://www.rssboard.org/rss-specification.

In a real world application, we?d probably load data from an RSS feedlocated at an external Web site. However, for simplicity we?ll load itfrom a local XML file. Because of the Ajax security sandbox, you?d needto use a proxy file written in a server-side language to create a localcopy of any externally located feeds. That?s a little beyond the scopeof today?s article but you can find lots of articles on the Web aboutthis topic.

If we wanted to create a Web 1.0 version of this application, we?d haveto rely on a Meta refresh directive to reload the page at regularintervals. If the feed was included in a page along with otherinformation, the user would have to wait until the entire page reloadedto see the other content. For example, if they were filling in a form,they could easily lose their place and have to start again. The Web 2.0approach allows the user to reload only the area containing the links,without refreshing the remaining page content.


Read More

Version: 
Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google