Ajax

From NetBurner Wiki

Jump to: navigation, search

Syncor Systems, Inc. - Using AJAX to Serve Dynamic Web Content on the NetBurner Platfom

A NetBurner solution will often monitor dynamic conditions like temperature and voltage. It is often desirable to see an updated view of this dynamic state data without manually refreshing the web client. It is a simple matter to make a web page dynamically refresh. However, the standard technique of using a metatag or JavaScript timeout setting causes the entire page to flash, which is often very distracting. This white paper describes a technique using AJAX that can keep sections of a page up to date in a seamless manner. This paper and attached code show you the low-level approach to using the XMLHttpRequest object. This is a good way to get your feet wet and will help you understand exactly how AJAX works. Once you have gained familiarity with the basic technique you can save time and effort by using one of the open source libraries (like Prototype) to help make your application more robust and work across all common browser platforms. This paper is accompanied by a zipped DevC++ project containing all the code. NOTE: The code in the sample does not address an issue where Internet Explorer gets overly agressive about caching AJAX requests. The recommended way to address this issue is to use the SetRequestHeader method on the request object as shown below:

var requestObject = CreateRequestObject();
requestObject.SetRequestHeader('If-Modified-Since','Sat, 1 Jan 2000 00:00:00 GMT');

ZipICO.PNG Download the source code here! Info_circle.png

Ajax Part II

Syncor Systems, Inc. uploaded a new library in early 2010 that makes use of the Prototype library and includes a large portion of their own JavaScript library. Once you understand the basics of AJAX you should find that using these libraries allows you to deploy more robust solutions in considerably less time. While there is no white paper for this version there is a blog entry and associated screencast showing you how to use the code.


Personal tools