jueves, 11 de abril de 2013

Ejemplo sencillo usando Phery


<?php
//Ensure that it's completly compatible with strict mode and throws no notices or warnings, and not using any deprecated code
error_reporting(-1);

if (version_compare(PHP_VERSION, '5.3.3', '<'))
{
 die('This demo needs at least PHP 5.3.3');
}

ini_set('display_errors', 1);

$end_line = 890; date_default_timezone_set('UTC');
$memory_start = 0;
$start_time = microtime(true);

require_once 'Phery.php';

ob_start();   
 
function common(){
  $r = new PheryResponse;
  $r->jquery("#result")->remove(); // load your messages
  return $r;
}

Phery::instance()->set(array(
  'common' => 'common'
))->process();
?>
<!doctype html>
<html>
<head>
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
  <meta charset="utf-8">
  <title>Phery</title>
  <script src="phery.js" type="text/javascript"></script>
  <script>
  $(document).ready(function(){
  
    $(function(){
  phery.remote('common');
});

  });
  </script>
</head>
<body style="background-color:red">
  <?php echo Phery::link_to('Click me', 'alias-for-function', array('class' => 'className', 'args' => array('data' => 'hallelujah'))) ?>
  <div id="result">Este contenido no se ve</div>
</body>
</html> 
 
OJO hace una doble petición el servidor este ejemplo 

No hay comentarios:

Publicar un comentario