无法从序列化数据中获取值

时间:2017-10-23 07:31:24

标签: php jquery ajax forms serialization

实际上我只是试图从序列化中获取所有输入数据,但我得到int类型的值,如age& id但无法获取名称的值。 以下是我的代码。

    <html>
    <body>
        <form id ="form" method="post" class= "form">
            Name<input type = "text" name = "name" /><br>
            Age<input type = "number" name = "age" /><br>
            ID<input type = "number" name = "id" /><br>
            <input type = "submit" name = "submit"><br/>
        </form>
        <p id="result"></p>
        <script
            src="https://code.jquery.com/jquery-3.2.1.min.js"
            integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
        crossorigin="anonymous"></script>
        <script>
            $(document).ready(function () {
                $("#form").submit(function () {
                    var data = $("#form").serialize();
                    insertStudent(data);
                    return false;
                });
                function insertStudent(data) {
                    $.ajax({
                        url: 'process.php',
                        data: data,
                        type: 'POST',
                        dataType: 'json',
                        success: function (data, textStatus) {
                            $("#result").html(data);
                        },
                        error: function () {
                            alert('Not OKay');
                        }
                    });
                }
            });
        </script>
    </body>
</html>

process.php

print_r($_POST);// give error but if i try to get id then
print_r($_POST["id"])// print value
print_r($_POST["name"])// doesn't print name

1 个答案:

答案 0 :(得分:0)

pkt=IPv6/IPv6ExtHdrRouting/ICMPv6EchoRequest
pkt2=pkt[ICMPv6EchoRequest]
pkt[IPv6].remove_payload()
pkt /=pkt2