Rumah >pembangunan bahagian belakang >tutorial php >利用Pear:HTML_AJAX提交表单时数组只提交了第一个值解决思路

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

WBOY
WBOYasal
2016-06-13 10:08:10752semak imbas

利用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把这个当属性了吧?
Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn