![]() |
![]() |
||||||
|
|||||||
Development & IT > AJAX with ExSite posted on 1:39 PM, September 24, 2007
AJAX stands for Asynchronous Javascript And XML, which has become a bit
of a misnomer. The term is generally used to refer to the
technique of loading some content after the main page is loaded, using
Javascript calls to fetch the content, and DHTML manipulations to
update the DOM. This technique has a few benefits:
ExSite provides a simple AJAX interface that works with any ExSite plug-in. The plug-in does not have to be written with an understanding of AJAX. ExSite manages the AJAX protocol on behalf of the plug-in, which means that every plug-in is automatically AJAX-capable. That is to say, an ExSite plug-in will work as a conventional web application or an AJAX plug-in with no extra effort on behalf of the programmer. How to run a plug-in in AJAX modePlug-ins are invoked using a specially-formatted HTML tag that looks like this:<!--&MyPlugin(parameters)-->where "MyPlugin" is the name of the plug-in being invoked, and "parameters" is an optional parameter string that gets passed to the plug-in to request particular types of output. The above syntax invokes the plug-in in conventional mode; the plug-in content is fetched at the time the page is built, and inlined into the HTML that is returned to the client browser. If the plug-in generates any self-referential links, those will regenerate the entire page from scratch. To invoke the plug-in in AJAX mode, simply add an extra ampersand to the above tag: <!--&&MyPlugin(parameters)-->Now the plug-in runs in a different manner altogether. The plug-in is not actually invoked at all when the page is built. Instead, we insert some basic Javascript to invoke the plug-in as part of a separate web request. This Javascript will insert exactly the same content you see in the previous method, so for the end user there is no difference in the final result (assuming they have Javascript running and a working internet connection). However, because the previous method generated self-referential links that regenerate the whole page, you will jump out of AJAX mode if you follow any of those links. To have all of the plug-in links be AJAX-enabled so that you stay in AJAX mode as you click your way through the plug-in data, add one more ampersand to the above tag: <!--&&&MyPlugin(parameters)-->Now, all of the self-referential links are modified to be AJAX-friendly. As long as you stay within your plug-in's links, your main page is never refreshed, and you may experience a faster, smoother interface to the plug-in. Which Plug-in Method Should I Use?Use full-AJAX (triple-ampersand) when:
ExamplesThe Calendar plug-in allows the viewer to browse through various month views and check out the events scheduled in each month. Many sites desire to include a "preview" of upcoming events in a sidebar or other secondary content area on published pages (especially the home page, index.html). This can be a problem if those pages are published infrequently, since the preview will become stale. Half-AJAX solves this problem by generating the preview dynamically and inserting it into the older published page:<!--&&Calendar(upcoming)-->The SlideShow plug-in allows the viewer to page through the various images in an album/library. Each click to the next image redraws the entire page, which is both slow and jerky. You can get a smoother slideshow effect by running in full-AJAX mode, so that the main page is unaffected, and only the slideshow itself is updated: <!--&&&SlideShow()-->Note that the slideshow will be smoothest if the images are all of the same or similar dimensions. Widely-differing image sizes may cause the page itself to reflow as each new image is inserted. Best PracticesAlthough the plug-in programmer does not have to go to special effort to support AJAX, you still must follow some standard practices to ensure that your plug-in will behave as ExSite expects:
|
Recent ArticlesDocumentation Topicsbest practices (5)
content management (12)
data handling (7)
fundamentals (3)
google (5)
graphic design (21)
html formatting (7)
IT (8)
plug-in modules (28)
POD (32)
programming (48)
RSS (3)
security (3)
SEO (3)
visual tutorial (29)
web protocols (9)
|