Pear::HTML_AJAX を使用してフォームを送信する場合、配列の最初の値のみが送信されます
User.php
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <?php class User{ function additem(){ // session_start(); // $u = $_SESSION["User"]; $item = array('name'=>$_POST["name"], 'sex'=>$_POST["sex"], 'age'=>$_POST["age"]); // $u[] = $item; // $_SESSION["User"] = $u; // return $u; return $item; } } ?>
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <?php session_start(); include 'HTML/AJAX/Server.php'; include 'User.php'; $server = new HTML_AJAX_Server(); $u = new User(); $server->registerClass($u); $server->handleRequest(); ?>
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>index</title> <script type="text/javascript" src="server.php?client=all&stub=all"></script> <script type="text/javascript"> function test(r){ var target = HTML_AJAX_Util.getElement("target"); var s = ''; /* for (var i=0; i<r.length; i++) { var rowdata = r[i]; s += '<h4>sex:'+rowdata["sex"]+'</h4><br>'; s += '<h4>name:'+rowdata["name"]+'</h4><br>'; s += '<h4>age:'+rowdata["age"]+'</h4><br>'; }*/ var rowdata = r; s += '<h4>name:'+rowdata["name"]+'</h4><br>'; s += '<h4>sex:'+rowdata["sex"]+'</h4><br>'; s += '<h4>age:'+rowdata["age"]+'</h4><br>'; target.innerHTML = s; } </script> </head> <body> <pre id="target">