Jan 23
AJAX Reference (XMLHttpRequest, Prototype and JSON)
1. Start from w3schools Javascript tutorial and oo javascript tutorial.
2. w3schools AJAX tutorial (using XMLHttpRequest object)
Demos from w3schools:
3. Prototype
3.1 Ajax
new Ajax.Updater('txtHint','prototype.php', {
method:'get',
insertion: Insertion.Top
});
new Ajax.PeriodicalUpdater('txtHint','prototype.php', {
method:'get',
insertion: Insertion.Top,
frequency: 1,
decay: 2
});
3.2 Prototype & JSON
a sample json object used:
{"hi":"Hi from the server!!! ","hi_in_korean":"uc548ub1fd!!!"}
new Ajax.Request(’prototype2.php’, {
method:’get’,
requestHeaders: {Accept: ‘application/json’},
onSuccess: function(transport){
var json = transport.responseText.evalJSON(true);
var pre = $(’txtHint’).innerHTML + “<br />”;
var output = pre + json.hi + json.hi_in_korean;
$(’txtHint’).update(output);
}
});
3.3. Prototype & JSON tutorial by AjaxLessons.com
No Comments
Leave a comment