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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
<?php
//
//Notre fonction PHP pour afficher les messages
//
function afficher()
{
$reponse = new xajaxResponse();
$test = '';
$test = document.getElementById('nom').value;
$reponse->assign('block', 'innerHTML', $test);
return $reponse;
}
require_once('./xajax_core/xajax.inc.php');
$xajax = new xajax();
$xajax->register(XAJAX_FUNCTION, 'afficher');
$xajax->processRequest();//Fonction qui va se charger de générer le Javascript, à partir des données que l'on a fournies à xAjax APRES AVOIR DECLARE NOS FONCTIONS
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>Chat xAjax</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?php $xajax->printJavascript(); /* Affiche le Javascript */?>
<script type="text/javascript">
function refresh()//script javascript qui va appeler le fonction afficher toutes les 5 secondes
{
xajax_afficher();
setTimeout(refresh, 5000);
}
</script>
</head>
<body>
<form action="index.php" method="post" class="important">
<p>
<SPAN TITLE="nom">Nom :</SPAN><div id="block"></div><input type="text" name ="nom"id="nom" maxlength="50" value ="monNom"/><br/>
</p>
<input type="submit" value="Modifier vos données"name="creer" /><br/>
</form>
<script type="text/javascript">
refresh();//On appelle la fonction refresh() pour lancer le script
</script>
</body>
</html> |
Partager