首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >未获取$_POST数据

未获取$_POST数据
EN

Stack Overflow用户
提问于 2018-07-21 06:04:30
回答 1查看 137关注 0票数 -1

我从来没有遇到过现在这样的情况。我在网站的另一部分使用这个设置。我不明白为什么我没有得到任何post数据,我的会话变量从不更新。

下面是html表单,动态创建一行复选框:

$html .= '<form id="status_form">';
    foreach ($leads as $key => $type) {
        $html .= '<input type="checkbox" name"' . $key . '" id="' . $key . '" class="box_status" value="1"';
        if (something = true) {
            $html .= ' checked="checked"';
        }
        $html .= ' />';
        $html .= '<label class="checkbox-inline" for"' . $key . '">' . $type . ' (' . @$count[$key] . ')</label>';
    }
    $html .= '</form>';

    echo $html;

每次选中复选框时,javascript都会提交表单,主要是更新会话变量,然后重新加载页面:

function update_report() {
            var form_data = $("#status_form").serialize();
            $.ajax({
                type: 'POST',
                url: 'scripts/test.php',
                data: form_data,
                success: function() {
                    window.location.reload(true);
                }
            });
        }

        $('.box_status').change(function(){
            update_report();
        });

下面是test.php文件:

session_start();

if (isset ($_POST)) {

  $_SESSION['crm']['reports']['index'] = array();

    foreach ($_POST as $k => $v) {
        $_SESSION['crm']['reports']['index'][] = $k;
    }

    $_SESSION['post'] = $_POST;

    echo true;
}

我已经仔细检查过了,表单显示正确,ajax进行了调用,我已经在test.php中做了"hello world“检查。它甚至进入if(isset($_POST))部分,但是会话变量没有改变,如果我将$_POST赋给另一个会话变量,它什么也不会显示。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51450940

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档