Login   Register  
PHP Classes
elePHPant
Icontem

File: Example.MyAjax3.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Adnan Alabuo  >  My Ajax  >  Example.MyAjax3.php  >  Download  
File: Example.MyAjax3.php
Role: Example script
Content type: text/plain
Description: for v3.0b
Class: My Ajax
Generate HTML to update pages using AJAX
Author: By
Last change: change name
Date: 3 years ago
Size: 3,952 bytes
 

Contents

Class file image Download
<?php

if (!empty($_POST['Text'])) {
    
sleep(3);
    echo 
$_POST['Text'];
    if (isset(
$_POST['Text2'])) { echo $_POST['Text2']; }
    exit;
}


if (!empty(
$_GET['Text'])) {
    
sleep(3);
    echo 
$_GET['Text'];
    exit;
}


include(
'class.MyAjax3.php');

?>

<html>
<head>
    <meta charset="utf-8" />
    <title>MyAjax v3</title>

<script language='javascript'>
function GetFormNotEmpty() {
    if (document.f.Text.value == ''){
        alert('Plz Fill This Field')
        document.f.Text.focus
        return false
    } else {
        return true
    }
}

function PostFormNotEmpty() {

    if (document.f2.Text.value == ''){
        alert('Plz Fill This Field')
        document.f2.Text.focus
        return false
    } else {
        return true
    }

}
</script>
<?
$MyAjax 
= new MyAjax;

$MyAjax->ErrorZone 'ErrorZone';
$MyAjax->Messages["NoError"] = '<h1>Server Status OK...</h1>';
$MyAjax->Messages["CanNotExeAjax"] = 'MSXML is not installed on your system.';
$MyAjax->Messages["BrowesErrorVersion"] = "Couldn't create connection object.";
$MyAjax->Messages["LoadingMessage"] = '<img src="ajax-loader.gif" border="0"><br />Loading...';
$MyAjax->Messages["ServerBusy"] = '<h1>Server Busy...</h1>';
$MyAjax->Messages["EmptyResponse"] = 'Empty Response';

//$MyAjax->Timeout = 10000;

#function addGetFunction ($FunctionName,$AjaxZoneID,$Link,$CallLoading=true,$UserArgs=false)
$MyAjax->addGetFunction('MyGetFunction','GETZONE','Example.MyAjax3.php?Text=MyGetFunction',true,false);
$MyAjax->addGetFunction('MyGetFunctionWithArguments','GETZONE','Example.MyAjax3.php?Text=',true,true);

#function addPostFunction ($FunctionName,$AjaxZoneID,$FormID,$Page='',$CallLoading='true',$UserArgs=false)
$MyAjax->addPostFunction('MyPostFunction','POSTZONE','f1','Example.MyAjax3.php',true,false);
$MyAjax->addPostFunction('MyPostFunctionWithArguments','POSTZONE','f2','Example.MyAjax3.php',true,true);

//$MyAjax->useErrorZone('ErrorZoneID');
$MyAjax->cancelErrorZone();

$MyAjax->printHeaderJS('./');

// it must be after $MyAjax->PrintHeaderJS();
$MyAjax->printJS();

/**
 *  you can us to print the function directly but it must be after $MyAjax->PrintHeaderJS();
 **/
#function printGetFunction ($FunctionName,$AjaxZoneID,$Link,$CallLoading=true,$UserArgs=false)
//$MyAjax->printGetFunction('MyGetFunction','GETZONE','Example.MyAjax3.php?Text=MyGetFunction',true,false);
//$MyAjax->printGetFunction('MyGetFunctionWithArguments','GETZONE','Example.MyAjax3.php?Text=',true,true);

#function AddPostFunction ($FunctionName,$AjaxZoneID,$FormID,$Page='',$CallLoading=true,$UserArgs=false)
//$MyAjax->printPostFunction('MyPostFunction','POSTZONE','f1','Example.MyAjax3.php',true,false);
//$MyAjax->printPostFunction('MyPostFunctionWithArguments','POSTZONE','f2','Example.MyAjax3.php',true,true);
?>
</head>

<body>

<div align="center">

<table border="1" width="684" height="96">
    <tr>
        <td height="42" width="50%" align="center">

        <div id="GETZONE">&nbsp;</div>

        <br />
        <input type="button" value="Get Function Without Argments" onclick="MyGetFunction()">
        
        <form id="f" name="f">
        <input type="text" name="Text">
        <input type="button" value="إرساف" onclick="javascript:if (GetFormNotEmpty()) { MyGetFunctionWithArguments(document.f.Text.value) }">
        </form>

        </td>
    </tr>
    <tr>
        <td height="42" width="50%" align="center">

        <div id="POSTZONE">&nbsp;</div>
<form id="f1" name="f1"><input type="hidden" name="Text" value="MyPostFunctionWithOutArguments"></form>
        <input type="button" value="Post Function Without Argments" onclick="MyPostFunction()">

        <form id="f2" name="f2">
        <input type="text" name="Text">
        <input type="button" value="إرساف" onclick="javascript:if (PostFormNotEmpty()) { MyPostFunctionWithArguments('Text2='+document.f.Text.value) }">
        </form>

        </td>
    </tr>

    </tr>
        <td><div id="ErrorZone">&nbsp;</div></td>
    </tr>

</table>

</div>

</body>

</html>