PHP Classes

File: Example.MyAjax2.php

Recommend this page to a friend!
  Classes of Adnan Alabuo   My Ajax   Example.MyAjax2.php   Download  
File: Example.MyAjax2.php
Role: Example script
Content type: text/plain
Description: v2
Class: My Ajax
Generate HTML to update pages using AJAX
Author: By
Last change:
Date: 13 years ago
Size: 3,123 bytes
 

Contents

Class file image Download
<?php

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


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


include(
'class.MyAjax.php');

?>

<html dir="rtl">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<title>صفحة جديدة 1</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.MyAjax.php?Text=MyGetFunction',true,false);
$MyAjax->AddGetFunction('MyGetFunctionWithArguments','GETZONE','Example.MyAjax.php?Text=',true,true);

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

$MyAjax->PrintJS();

?>
</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>