Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/AjaxTest/testAjax.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Yaroslav Shapoval  >  Cyrillic to Latin  >  examples/AjaxTest/testAjax.php  >  Download  
File: examples/AjaxTest/testAjax.php
Role: Example script
Content type: text/plain
Description: Ajax test script
Class: Cyrillic to Latin
Translite text between cyrillic and latin
Author: By
Last change: Important usage demo added. Example shows usage of class with Ajax technology.
Date: 8 years ago
Size: 906 bytes
 

Contents

Class file image Download
<html>

<body>
<script language="JavaScript" src="lib/Js.js"></script>
<script>
    function doLoad(force) {
        var query = '' + document.getElementById('query').value;
        var req = new Subsys_JsHttpRequest_Js();
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                if (req.responseJS) {
                        document.getElementById('result').innerHTML=
        (req.responseJS.cyr||'');
                }


            }
        }

        req.caching = true;
        req.open('POST', 'lat2cyr.php?input=abc', true);
        req.send({ q: query, test:303 });
    }

    var timeout = null;
    function doLoadUp() {
        if (timeout) clearTimeout(timeout);
        timeout = setTimeout(doLoad, 1000);
    }
</script>

<form onsubmit="return false">
Type phrase using latin symbols<br />
<textarea type="text" id="query" onkeyup="doLoadUp()"></textarea>
</form>

<p>Result:</p>
<pre>
<div id="result"></div>
</pre>



</body>
</html>