DZone 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

Snippets has posted 5883 posts at DZone. View Full User Profile

Ultra Simple Prototype.js AJAX Example

  • submit to reddit
        Taken <a href="">from</a> the great <a href="">Amy Hoy</a>.

<h2>ajax replacing link</h2>
<a href="backend.php?return=time" 
   onclick="new Ajax.Updater('testdiv', 'backend.php?return=time',
   {asynchronous:true, evalScripts:true }); return false;">
This link updates a line</a>
<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.    


Snippets Manager replied on Tue, 2008/06/10 - 5:03pm

muy bueno.