PHP Classes
elePHPant
Icontem

File: en/test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Eduardo Martos Gómez  >  iAJAX  >  en/test.php  >  Download  
File: en/test.php
Role: Example script
Content type: text/plain
Description: Test script
Class: iAJAX
Trigger an AJAX request upon an HTML page event
Author: By
Last change: Bad reference.
Date: 8 years ago
Size: 1,189 bytes
 

Contents

Class file image Download
<html>
<head>
<title>Testing iAJAX</title>
<?php
   
// 1. AJAX class reference
   
include_once ("cls_iajax.php");
   
   
// 2. AJAX object creation
   
$iAJAX = new iAJAX;
   
// 3. ajax.js reference
   
echo $iAJAX->head_ref ();
?>
</head>
<body>
<?php
   
// 4. Needed architecture modification:
    // If there's no AJAX call, it shows the container objeto_modificable.
    // If there's AJAX call, it doesn't show the container, but its value.
    //
    // Note 1: This modification of the site's architecture is only a suggestion,
    // not the only way.
    // Note 2: It's recommended to use href="javascript:void(0);", compatible
    // with Mozilla and Trident engines.
   
if (!isset ($_GET["modo"]))
    {
        echo
"<div id=\"objeto_modificable\">Initial content</div>\n".
           
"<a href=\"javascript:void(0);\" ".
               
$iAJAX->llamada_ajax ("objeto_modificable", "?modo=ajax").">Modify</a>&nbsp;\n".
           
"<a href=\"javascript:void(0);\" ".
               
$iAJAX->llamada_ajax ("objeto_modificable", "?modo=inicial").">Reset</a>\n";
    }
    elseif (
$_GET["modo"] == "ajax")
    {
        echo
"Updated content";
    }
    elseif (
$_GET["modo"] == "inicial")
    {
        echo
"Initial content";
    }
?>
</body>
</html>