<?php

include_once dirname(__FILE__) . '/../../Amfphp/Services/AppServer.php';
include_once dirname(__FILE__) . '/../../Amfphp/Services/TestServer.php';

?>

<html>
    <?php require_once dirname(__FILE__) . '/head.inc.tpl'; ?>
    <script type="text/javascript">
        function updateCallDialog(class_Name, method, params) {
            $("#className").text(method + " methond on " + class_Name);
            $("#myform").attr("action", "?go=index.php&do=call&className=" + class_Name + "&method=" + method);

            $("#args").empty();
            for (arg in params) {
                $("#args").append('<tr><td>' + params[arg].name + '</td><td><input name="' + params[arg].name + '"></td></tr>');
            }
            $("#result").empty();
            // $("#myform").one("submit",null,null,postCallParams);
        }
        ;

        function postCallParams() {
            var form = $("#myform");
            var url = form.attr("action");
            var data = form.serialize();

            $.ajax({
                type: "post",
                url: url,
                data: data,
                success: function (resp) {
                    $("#result").html(resp);
                },
                error: function () {
                    alert("err");
                }
            });
            return false; // 阻止表单自动提交事件
        }
        ;

    </script>
    <body>
    <?php require_once __DIR__ . '/header.tpl'; ?>
        <div id='main'>
            <div class="left">
                <b>   测试</b>
                <div class="menu">
                   <?php
                   ob_start();
                   Debug::listMethod('loyalsof\AppServer');
                   Debug::listMethod('loyalsoft\TestServer');
                   ob_end_flush();
                   ?>

                </div>
            </div>

            <div style="position: relative; top: 0px;clear: right;" class="userInput" id="callDialog">
                <h3><b id="className">api method on AppServer service</b></h3>
                复杂参数, 请使用RequestVo的JSON编码格式.
                <form id="myform" action="?go=index.php&do=call" method="POST">
                    <table>
                        <tbody id="args">
                            <tr><td>request</td><td><input name="request" /></td></tr>
                        </tbody>
                    </table>
                    <input type="button" value="Call method »" onclick="postCallParams();" />
                </form>
            </div>
            <div style="position: relative; top: 0px;display: inline-block;float: none;" id="result"  >

            </div>
        </div>
    <?php require_once __DIR__ . '/footer.tpl'; ?>
    </body>
</html>



