Home arrow JavaScript arrow Page 2 - Creating a Dynamic Banner System with AJAX
JAVASCRIPT

Creating a Dynamic Banner System with AJAX


AJAX has proven itself useful in a variety of web applications. In this three-part article series, you will learn how to use AJAX to display commercial banners dynamically on your web site. This first article will show you how to develop the basic script.

Author Info:
By: Alejandro Gervasio
Rating: 4 stars4 stars4 stars4 stars4 stars / 12
July 30, 2007
TABLE OF CONTENTS:
  1. · Creating a Dynamic Banner System with AJAX
  2. · Creating a system of dynamic banners
  3. · Displaying the banners on the browser using AJAX
  4. · Completing the dynamic banner system
  5. · Listing the banner application's full source code

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Creating a Dynamic Banner System with AJAX - Creating a system of dynamic banners
(Page 2 of 5 )

The first step involved in building the dynamic banner system is creating a simple front-end, which will be used by the system to display different banners in a predefined time sequence.

In simple terms, the only requirement to get this AJAX-based application working is the definition of a generic containing element within a web document, where all the banners will be shown, based on a pre-established period of time.

So, considering this condition, below I built a simple web graphic interface for displaying the banners. The source code that renders this interface is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-
8859-1" />
<title>AJAX-Driven Dynamic Banner System</title>
<style type="text/css">
body{
   margin: 0;
   padding: 0;
   background: #eee;
}

h1{
   text-align: center;
   font: bold 24px Arial, Helvetica, sans-serif;
   color: #000;
}

#bannercontainer{
   text-align: center;
   width: 180px;
   height: 400px;
   margin-left: auto;
   margin-right: auto;
   background: #fff;
   border: 1px solid #000;
}

#bannercontainer img{
   border: none;
}
</style>
</head>
<body>
  <h
1>AJAX-Driven Dynamic Banner System</h1>
 
<div id="bannercontainer"></div>
</body>
</html>

As you can see, the above (X)HTML file simply displays on the browser a rudimentary front-end composed of an <h1> header, and the pertinent banner container, in this case identified as "bannercontainer." Very simple, right?

However, the purpose of this tutorial isn't to show you how to code a basic web page, but demonstrate how to use it to display a predetermined set of dynamic banners via some HTTP request triggered through AJAX.

Therefore, here's where things get really interesting, since in the section to come I'm going to define a couple of JavaScript functions which will be responsible for fetching the banners from the web server and displaying them on the browser.

Want to learn more about how these JavaScript functions will look? Click on the link below and keep reading.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials