Wednesday, July 19, 2006

Ajax Library

I just came accross a great library for all web developers using Ajax. This library is a wrapper around the standard xmlhttp object with a lot of smart and helpful functions. The library is called Prototype and is availible here.

It's very simple to use:

Just include the script file on your web page and make a javascript-call to a function getAjaxContent(placeholder);

The function getAjaxContent() should look like this, depending of your needs:


function getAjaxContent(placeholder){
var url = 'http://yourserver/yourapp/yourpage';
var params = 'param1=1¶m2=2';
var myAjax = new Ajax.Updater(placeholder, url, { method: 'get', parameters: params });
}

You can of cource put the url and params as parameters to the function. The placeholder parameter is a string with the id of the element where you want to put the content.

Since this is only a javascript-file you can use it in all programming languages. I use it in .NET and it works wery good! You can download the prototype.js file here.