Prototype
Introduction[edit]
Library to support AJAX.
Using[edit]
Library[edit]
just add
<script type="text/javascript" src="prototype.js"></script>
to the header section of the html file.
Making a Request[edit]
Is by Definition asynchronous.
new Ajax.Request('<RelativeURL>',
{ method:'get',
parameters: {<Parametername>: <Value>, <ParameterName>: <Value>, ...}
<Callback>: function(transport)
{
var response = transport.responseText || "no response text";
alert("Success! \n\n" + response);
},
<Callback>: function()
{
...
}
});
Callbacks can be onSuccess, onFailure, onComplete, onException, ...
Passing Form Parameter[edit]
parameters: $('<FormName>').serialize(true)
Continous Update[edit]
new Ajax.PeriodicalUpdater('<ElementName>',
'<RelativeURL>',
{
method: 'get',
insertion: Insertion.Top,
frequency: 10, // seconds
decay: 2 // seconds
});