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

04.06.2006
| 33869 views |
  • submit to reddit
        Taken <a href="http://www.slash7.com/articles/2005/10/07/design-your-software-mdash-please">from</a> the great <a href="http://www.slash7.com/">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.    

Comments

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

muy bueno.