PHP Classes

File: gajax.example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Cesar D. Rodas  >  gAjax  >  gajax.example.php  >  Download  
File: gajax.example.php
Role: Example script
Content type: text/plain
Description: Test
Class: gAjax
Execute PHP functions from Javascript using AJAX
Author: By
Last change: * Fixing bug in example found by "kausar alam".
Date: 8 years ago
Size: 1,806 bytes


Class file image Download

function sumar($a,$b) {
$a + $b;
multiplicar($a,$b) {
$r = $a * $b;
$html = new gHtml;
$html->alert("This example also shows how to use gHttp");
/* Keep show the result in result2 */
$html->alert("result2 now was changed");
/* The result is also the new size of the HTML object with id ID*/
$html->setProperty('rows', $r);
$html->setProperty('value',"Long's text\ncesar");
$html->alert("now the value rows");
/* Return the result also to the default function */
$html->alert("now the value is returned, if there is a function that get the return, it will be changed");


$ajax = new gAjax('js/');

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cesar Rodas</title>

Calling the PHP function sumar(5,10) = <span id="result"></span>
->execute("result","sumar",5, 10);
    A=<input type="text" id="a" /><br />
    B=<input type="text" id="b" /><br />
    AxB = <span id="result1"> (normal)</span><br />
    AxB = <span id="result2"> (gHttp)</span><br />
    <input type="button" onclick="<? $ajax->execute('result1',false,"multiplicar",byvalue('a','value'), byvalue('b','value') );?>" value="Multiplicar!" /><br />
    <textarea id = 'id' cols=40 rows=10></textarea>