O'Reilly logo

YUI 2.8 Learning the Library by Dan Wellman, Daniel Barreiro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Basic communication

In our first example we will send a number to our server, which will reply with that number squared. This is all the code we will use on our server:

<?php
$val = floatval($_REQUEST["value"]);
echo ($val * $val);
?>

If we type in our browser http://localhost/yuisite/squared.php?value=5 we will get back 25. This simple server script shows us something very important. Although the AJAX transactions are transparent to our users, they are very simple HTTP requests, which we can initiate from our browsers, so a good way to test if our server is responding appropriately is to simply type a request and see what comes back. Also, as we see in this example, there doesn't need to be any XML involved at all.

Using our usual template for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required