Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Peter Cooperx http://www.petercooper.co.uk/

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Ultra simple Prototype.js AJAX example

Taken from the great Amy Hoy.

   1  <h2>ajax replacing link</h2>
   2  <a href="backend.php?return=time" 
   3     onclick="new Ajax.Updater('testdiv', 'backend.php?return=time',
   4     {asynchronous:true, evalScripts:true }); return false;">
   5  This link updates a line</a>
   6  <div id="testdiv"></div>


With no JavaScript turned on, it'll go to the normal URL. Without, it'll do an XMLHTTPRequest and put the result in #testdiv.

Scriptaculous JavaScript slideshow

Found this amazing code by obie at http://blog.caboo.se/articles/2006/01/19/easy-scriptaculous-slideshow:

   1  var album = { 
   2    startup: function() { 
   3      new PeriodicalExecuter(album.cycle, 5) // change image every 5 seconds 
   4    }, 
   5    cycle: function() { 
   6      new Effect.Fade('image', { // the id of the <DIV> containing the photos 
   7        duration: 1, 
   8        fps: 50, 
   9        afterFinish: function() { 
  10          new Ajax.Updater('image','/album/next', { // URL for next <IMG> tag 
  11            asynchronous: true, 
  12            onSuccess: function() { 
  13              new Effect.Appear('image', {
  14                duration: 1,
  15                fps: 50,
  16                queue:'end'
  17              })
  18            } 
  19          }) 
  20        } 
  21      }) 
  22    } 
  23  } 
  24   
  25  window.onload = album.startup


I want to tweak it so that an earlier event precaches the next image instead.
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS