PHP Classes

File: villes/php5/oajax.cls.php

Recommend this page to a friend!
  Classes of Johan Barbier   Cities and zip codes   villes/php5/oajax.cls.php   Download  
File: villes/php5/oajax.cls.php
Role: Class source
Content type: text/plain
Description: PHP5 oajax class
Class: Cities and zip codes
Lookup for cities and zip codes using AJAX
Author: By
Last change: changed everything!
Date: 16 years ago
Size: 1,121 bytes
 

Contents

Class file image Download
<?php
class oajax {

    public function
setHeader () {
       
$sString = <<<HTML
<script type="text/javascript">
HTML;
        return
$sString;
    }

    public function
setFooter () {
       
$sString = <<<HTML
</script>
HTML;
        return
$sString;
    }

    public function
buildAjax () {
       
$sString =<<<HTML

        if (window.XMLHttpRequest) {
            oXmlhttp = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
            oXmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }

HTML;
        return
$sString;
        }

    public function
search () {
       
$sString =<<<HTML
function search (sS, bSort, iType) {
    if (sS != '') {
        oXmlhttp.open('POST','
{$_SERVER['PHP_SELF']}');
        oXmlhttp.onreadystatechange=function() {
            if (oXmlhttp.readyState==4 && oXmlhttp.status == 200) {
                //document.body.innerHTML = oXmlhttp.responseText;
                document.getElementById ('divContent').innerHTML = oXmlhttp.responseText;
            }
        }
        oXmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        var data = 'data='+sS+'&sort='+bSort+'&type='+iType;
        oXmlhttp.send (data);
    }
}

HTML;
    return
$sString;
    }
}
?>