javascript - 清空 $_POST。值最终以 $GLOBAL 结尾

标签 javascript php jquery html

自从我重新安装操作系统以来,我一直在努力解决一个奇怪的 $_POST 问题。我决定回去处理我的一个空闲时间项目,我注意到我的所有 POST 请求都不起作用,但我确信它们以前曾起作用。

我注意到,所有 $_POST 值总是以 $GLOBALS 结束,而 $_POST 数组始终为空。有什么想法吗?

使用 PHP 版本 5.6.19

php.ini:

https://dl.dropboxusercontent.com/u/42704655/php.ini

脚本:

    $('#login-form').on('submit', function () {
    $.ajax({
        type: "POST",
        url: "php/login.php",
        data: $("#login-form").serialize(),
        success: function (data) {
    });

    return false;
});

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/login.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js" async></script>
    <script src="scripts/login-script.js" async></script>
</head>
<body>
<div id="wrapper">
    <div id="login">
        <form method="post" id="login-form" action="php/login.php">
            <table>
                <tr>
                    <td>Login:</td>
                    <td><input type="text" name="login" form="login-form" class="input" autofocus></td>
                </tr>
                <tr>
                    <td>Password:</td>
                    <td><input type="password" name="password" form="login-form" class="input"></td>
                </tr>
                <tr>
                    <td colspan="2">
                        <button type="submit" form="login-form">Login</button>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" id="input-td">
                        <p id="errorMsgs"></p>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>

</body>
</html>

PHP

<?php
print_r($_POST);

$GLOBALS(“test1”作为登录名,“test2”作为密码)

array(8) { ["HTTP_RAW_POST_DATA"]=> string(26) "login=test1&password=test2" ["_GET"]=> array(0) { } ["_POST"]=> array(0) { } ["_COOKIE"]=> array(0) { } ["_FILES"]=> array(0) { } ["GLOBALS"]=> *RECURSION* ["login"]=> string(0) "" ["pass"]=> string(0) "" }

最佳答案

我想我刚刚明白了。我的 IDE 中内置的网络服务器存在一些错误。 https://intellij-support.jetbrains.com/hc/en-us/community/posts/206999125-PhPStorm-10-does-not-allow-POST-method

关于javascript - 清空 $_POST。值最终以 $GLOBAL 结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36071722/

相关文章:

javascript - 当用户手指超出溢出-y :scroll element? 时如何结束滚动

php - 在 php 中格式化 linux 命令输出

javascript - jQuery:忽略选择器中的类

javascript - Webpack 在使用继承缩小/丑化 ES6 代码时删除了类名

javascript - 将表单字段内容传递到新页面上的同一表单字段

javascript - 不允许出现单个 "-",但在正则表达式中仍然允许负值和金钱

php - Mongodb php获取新文档的ID?

php - Wordpress 索引页面上的特定 CSS

javascript - 如何将一种形式正确放置在另一种形式之前?

Javascript Marquee 文本被剪裁为大字体