Rico and prototype

Rico (hiszp. bogaty) – biblioteka javascriptowa, która wraz z prototype.js pozwala na proste animacje, drag-and-drop na stronce, wszystko na bazie architektury AJAX

http://openrico.org/

Przykładowa strona – komunikacja z serwerem. Kod z biblioteką Rico jest teraz bardziej przejrzysty.

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”&gt;
<html>
<head>
<title>Testujac OpenRico</title>
<script src=”prototype.js” ></script>
<script src=”rico.js” ></script>
<script type = “text/javascript“>
function callRICO()
{
ajaxEngine.registerRequest(‘myRequest’,’ricotest.php’);
ajaxEngine.registerAjaxElement(‘display’);
ajaxEngine.registerAjaxElement(‘heading’);
}
</script>
</head>
<body onLoad = “callRICO()“>
<div id = “heading”><h3>Demonstracja Rico</h3></div>
<input type = “button” value = “Pobierz dane z serwera” onclick = “ajaxEngine.sendRequest(‘myRequest’);”/>
<div id = “display”><p>Ten tekst powinien zostac zastapiony tekstem z serwera…</p></div>
</body>
</html>

ricotest.php:

<?php
header(“Content-Type: text/xml”);
header(“Cache-Control: no-cache”);
header(“Pragma: no-cache”);
echo “<ajax-response><response type=\”element\”
id=\”display\”><p>”.$_SERVER[‘SERVER_SIGNATURE’].”
</p></response><response type=\”element\” id=\”heading\”>
<h3>Kilka informacji o serwerze</h3></response></ajax-response>”;
?>

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s