Prototype js Quick Ajax Primer

Post

For those budding developers out there looking to get into ajax, here is a short tutorial of an easy way to ease into it.
If you haven't yet looked into a javascript framework such as prototype, now is the time to do so.
Prototype gives a quick and easy way to do some simple ajax calls from your javascripts without doing a lot of work.

For example, if you wanted to submit a variable to a backend page, putting the result of the call into a html element.

[code]
function superButtonClick() {
new Ajax.Updater('id_of_the_element','/backend_page.php', {
method: 'get',
parameters: {the_variable_name: 'the_variable_value'}

});
}
[/code]

That simple snippet when called from a button onClick will fetch the results of url "backend_page.php?the_variable_name=the_variable_value" and place them into a html element with the id "id_of_the_element".

It's really that simple to make an ajax call using the prototype js framework.

Comments

Leave a comment

November 2026
Sun
Mon
Tue
Wed
Thu
Fri
Sat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Share