Reply to Re: Just what is "Ajax" ???

Your name:

Reply:


Posted by Toby Inkster on 11/12/56 11:39

Noozer wrote:

> Just what is Ajax? Is it just a "way" to code a webpage? Is it a different
> language, like VB.Net or Java?

It is something that you can do by combining a few existing technologies:

- Javascript;
- A server-side scripting language; and
- XML

Here's a basic pseudo-code example of AJAX:

<html>
<script type="PSEUDO-CODE">
function ajaxFunc ()
{
a = document.getElementById("a").value;
b = document.getElementById("b").value;
xrt = new XML_Request_Thingy();
xrt.open("http://example.org/myscript.php?a=" + a + "&b=" + b);
c = xrt.response();
alert("The answer is " + c);
}
</script>
<form>
<input name="a" id="a"> +
<input name="b" id="b">
<input type="submit" onclick="ajaxFunc();" value="Add!">
</form>
</html>

and here is myscript.php:

<?php
$a = (int)$_GET['a'];
$b = (int)$_GET['b'];
$c = $a + $b;
header("Content-Type: text/xml");
print $c;
?>

Do you see what's happened?

1. Client-side Javascript has some information (in the
example, it has 'a' and 'b').
2. It passes the information to a PHP script via an HTTP
request.
3. The PHP script does something with it (in this case,
adds the two numbers together).
4. The PHP script prints out its reply.
5. The Javascript receives the answer.
6. The Javascript does something with the answer.

The techology is now there for all the main browsers: IE 5.5+ (perhaps
5.0?), Gecko 1.1+ (?), Opera 8.5+, Safari 1.mumble+ and so on.

The example I presented is trivial -- the Javascript could have easily
done the adding itself -- but there are some things that it makes a lot of
sense to pass to the server for processing. Database access is one obvious
application.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация