Deprecated: Assigning the return value of new by reference is deprecated in /home/translation/www/blog/wp-includes/cache.php on line 36

Deprecated: Assigning the return value of new by reference is deprecated in /home/translation/www/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/translation/www/blog/wp-includes/theme.php on line 508
Vincent Park » AJAX Reference (XMLHttpRequest, Prototype and JSON)

Jan 23

AJAX Reference (XMLHttpRequest, Prototype and JSON)

Category: Programming

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