首頁  >  文章  >  後端開發  >  利用Pear:HTML_AJAX提交表单时数组只提交了第一个值解决思路

利用Pear:HTML_AJAX提交表单时数组只提交了第一个值解决思路

WBOY
WBOY原創
2016-06-13 10:08:10719瀏覽

利用Pear::HTML_AJAX提交表单时数组只提交了第一个值
User.php

PHP code
<!--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;        }    }?>


Server.php

PHP code
<!--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();?>


index.php

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><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"]+'<br>';        s += '<h4>name:'+rowdata["name"]+'<br>';        s += '<h4>age:'+rowdata["age"]+'<br>';    }*/    var rowdata = r;    s += '<h4>name:'+rowdata["name"]+'<br>';    s += '<h4>sex:'+rowdata["sex"]+'<br>';    s += '<h4>age:'+rowdata["age"]+'<br>';    target.innerHTML = s;}</script><pre id="target">



提交后只能显示name,而sex和age都是null,为什么?

------解决方案--------------------


name=sex" : HTML把这个当属性了吧?
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn