Home arrow JavaScript arrow Page 3 - Finishing a Slide Show Application with jQuery
JAVASCRIPT

Finishing a Slide Show Application with jQuery


In the preceding article of this series, I demonstrated how to take advantage of the jQuery JavaScript library's functionality to develop a simple slide show, which used the Ajax module bundled with jQuery as its driving engine. In this part, we'll finish the application.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
October 16, 2009
TABLE OF CONTENTS:
  1. · Finishing a Slide Show Application with jQuery
  2. · Listing the slide show application’s partial source code
  3. · Incorporating a JavaScript timer
  4. · Listing the application’s complete source code

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Finishing a Slide Show Application with jQuery - Incorporating a JavaScript timer
(Page 3 of 4 )

In the previous section, I explained that it was necessary to incorporate a simple JavaScript timer into the slide show built previously. This would provide the application with the capability to fetch automatically all of the images stored on the web server to be displayed later on the browser using a determined sequence.

To be frank, implementing this basic timer is a straightforward process that you'll certainly grasp very quickly. If you take a close look at the following JavaScript snippet, then you’ll realize how the slide show is now capable of automating the retrieval of images from the web server:

$(document).ready(getImage());

function getImage(){

$.ajax({

url: 'getimage.php',

type: 'GET',

dataType: 'html',

timeout: 1000,

error: function(){

alert('Error loading image!');

},

success: function(image){

$("#container").html(image);

}

});

setTimeout("getImage()",3000*1);

}

As demonstrated by the above code sample, I used the JavaScript “setTimeout()” method to automatically fetch a new image from the server every three seconds. Obviously, this parameter is completely customizable, and you should use the value that best fits your personal needs.

So, in summary, with the incorporation of this simple JavaScript timer, now the slide show is capable of displaying automatically different images on the browser via Ajax. In other words, at this point, this web application has the expected behavior.

However, there are a couple of additional steps that must be taken to finish developing this Ajax-driven slide show. Naturally, the first one consists of linking the JavaScript code that you saw before to the application’s structural markup, and the second one requires the creation of a few sample images that can be used to demonstrate in a nutshell how the slide show functions.

Therefore, in the following section, I’ll be showing you how to accomplish these tasks with minor hassles, thus completing the creation of this basic slide show using the jQuery library.

So, what are you waiting for? Click on the link that appears below and read the next few lines!


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 6 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials