/usr/share/php/xajax/tests/nonXajaxResponseTest.php is in php-xajax 0.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | <?php
require_once( "../xajax_core/xajax.inc.php" );
function testXajaxResponse( )
{
    // Return a xajax response object
    $objResponse=new xajaxResponse();
    $objResponse->assign( 'DataDiv', 'innerHTML', 'Xajax Response Data' );
    return $objResponse;
}
function testXmlResponse( )
{
    $objResponse=new xajaxCustomResponse( 'text/xml' );
    $objResponse->setCharacterEncoding( 'UTF-8' );
    $objResponse->append( '<?xml version="1.0" encoding="utf-8" ?' . '><root><data>text</data></root>' );
    return $objResponse;
}
function testTextResponse( )
{
    $objResponse=new xajaxCustomResponse( 'text/plain' );
    $objResponse->append( 'text data' );
    return $objResponse;
    // return text data directly to the custom response handler function
    return 'text data';
}
$xajax=new xajax();
$xajax->configure( 'debug', true );
$xajax->configure( 'useUncompressedScripts', true );
$xajax->configure( 'javascript URI', '../' );
// Tell xajax to permit registered functions to return data other than xajaxResponse objects
$xajax->configure( 'allowAllResponseTypes', true );
$callXajaxResponse=&$xajax->register( XAJAX_FUNCTION, 'testXajaxResponse' );
$callXmlResponse=&$xajax->register( XAJAX_FUNCTION, 'testXmlResponse', array('responseProcessor' => 'xmlResponse'));
$callTextResponse=&$xajax->register( XAJAX_FUNCTION, 'testTextResponse', array
    (
    'mode' => '"synchronous"',
    'responseProcessor' => 'textResponse'
    ));
$xajax->processRequest();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
    <head>
        <title>Non-xajaxResponse XML and Text Responses Test | xajax Tests</title>
        <?php $xajax->printJavascript() ?>
        <script>
            // function to handle ajax response text data
            function textResponse(objRequest)
                {
                xajax.$('DataDiv').innerHTML = objRequest.request.responseText;
                xajax.completeResponse(objRequest);
                }
            // function to handle ajax response data XML
            function xmlResponse(objRequest)
                {
                alert(objRequest.request.responseXML.documentElement.nodeName);
                xajax.$('DataDiv').innerHTML = 'non xajax: XML response';
                xajax.completeResponse(objRequest);
                }
        </script>
    </head>
    <body>
        <h2><a href = "index.php">xajax Tests</a></h2>
        <h1>Non-xajaxResponse XML and Text Responses Test</h1>
        <form id = "testForm1" onsubmit = "return false;">
            <p>
                <input type = "button"
                    value = "xajax" onclick = "<?php $callXajaxResponse->printScript(); ?>; return false;" />
                <!-- use xajax.call to call the functions that return data directly and 
                indicate the javascript function that will handle the response -->
                <input type = 'button' value = 'xml' onclick = '<?php $callXmlResponse->printScript(); ?>' />
                <input type = 'button' value = 'text' onclick = '<?php $callTextResponse->printScript(); ?>' />
            </p>
        </form>
        <div id = "DataDiv">
        </div>
    </body>
</html>
 |