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>
<h1>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.
Next: Displaying the banners on the browser using AJAX >>
More JavaScript Articles
More By Alejandro Gervasio