Home > Backend Development > PHP Tutorial > 利用Pear:HTML_AJAX提交表单时数组只提交了第一个值解决思路

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

WBOY
Release: 2016-06-13 10:08:10
Original
750 people have browsed it

利用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;        }    }?>
Copy after login


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();?>
Copy after login


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">
Copy after login



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

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


name=sex" : HTML把这个当属性了吧?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template