Doing AJAX with popular javascript libraries

| Basic | Prototype.js | Dojo Toolkit | Yahoo UI Library | ASP.NET | Rails |


Most javascript lovers must already be knowing this. Prototype.js is the legendary collection of javascript gems in a single file. AJAX in one of many things it does. Once you add reference to prototype.js you can make AJAX request like this:
new Ajax.Request(url,
    onSuccess: function(response){alert(response.responseText);},
    onFailure: function(){ alert('There was a problem.') }
You can assign following callback methods (in addition to onSuccess and onFailure).
That's not all, the library also has 'Ajax.Updater' which can be used to refresh a section of webpage with HTML coming from server
var myAjax = new Ajax.Updater(
    	 method: 'get',
    	 parameters: params
Here the contents of an element which whose id is 'placeholder_id' are replaced with response of the request. The AJAX request is made after appending the 'params' to the url. Prototype is a very well written javascript library. It can do incredible things.

Make sure you check out its website here:
  • Strongly recommended if you are doing complex stuff with javascript and AJAX.
  • Lightweight (about 46.3 Kb), compared to feature it provides.
  • Well designed, no matter what web development framework you use (ASP.NET,Rails,PHP…etc), you will find this very useful.
| Basic | Prototype.js | Dojo Toolkit | Yahoo UI Library | ASP.NET | Rails |

Copyright (c) 2007-2019 Ashish Patil . Please read FAQ for more details.

comments powered by Disqus