Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php jQuery$.post转换为GET请求_Php_Javascript_Jquery - Fatal编程技术网

Php jQuery$.post转换为GET请求

Php jQuery$.post转换为GET请求,php,javascript,jquery,Php,Javascript,Jquery,我有一点HTML: <form action="http://shoutzor.nl/login" method="POST" id="loginform" class="form-horizontal"> <fieldset> <legend>Have an account? Login!</legend> <div class="control-group"> <

我有一点HTML:

<form action="http://shoutzor.nl/login" method="POST" id="loginform" class="form-horizontal">
    <fieldset>
        <legend>Have an account? Login!</legend>
        <div class="control-group">
            <label class="control-label" for="username">Username</label>
            <div class="controls">
                <input type="text" id="username" name="username" />
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="password">Password</label>
            <div class="controls">
                <input type="text" id="password" name="password" />
            </div>
        </div>
        <div class="control-group">
            <div class="controls">
                <input type="submit" class="btn" value="Login" />
            </div>
        </div>
    </fieldset>
</form>
<form action="http://shoutzor.nl/login" method="POST" id="registerform"
class="form-horizontal">
    <fieldset>
        <legend>Create an account</legend>
        <div class="control-group">
            <label class="control-label" for="username">Username</label>
            <div class="controls">
                <input type="text" id="username" />
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="email">Email</label>
            <div class="controls">
                <input type="text" id="email" />
            </div>
        </div>
        <div class="control-group">
            <div class="controls">
                <input type="submit" class="btn" value="Register" />
            </div>
        </div>
    </fieldset>
</form>
在服务器端,我有自己的PHP API,但这并不重要,因为奇怪的是,即使在index.PHP文件的顶部,
$\u server['REQUEST\u METHOD']
也返回“GET”和
var\u dump($\u REQUEST)
根本不返回任何数据


我以前没有在我的任何其他网站上遇到过这个问题(这些网站使用的是我开发的同一个PHP CMS),所以我现在假设我的JavaScript代码有问题,但我没有发现这个问题。

my.htaccess确实重写了所有URL,以“/”结尾,因为我请求了(没有结尾“/”)它变成了一个我没有注意到的重定向


添加“/”解决了可能与此相关的问题:?@j08691有趣-从该链接,我认为可能是服务器将请求重定向到/login或/register@j08691我现在觉得自己很愚蠢,这确实解决了我的问题!非常感谢。不,别傻了,这是个棘手的问题。
$("form").submit(function (e) {
    e.preventDefault();

    $("body").toggleLoadMaskOverlay();

    if ($(this).is("#registerform")) {
        //Registreren
        $.post("http://shoutzor.nl/register ", {
            username: $("#registerform input[name=username]").val(),
            email: $("#registerform input[name=email]").val()
        }, function (result) {
            $("body").toggleLoadMaskOverlay();
        }, "json");
    } else {
        $.post("http://shoutzor.nl/login", {
            test: "test",
            username: $("#loginform input[name=username]").val(),
            password: $("#loginform input[name=password]").val()
        }, function (result) {
            $("body").toggleLoadMaskOverlay();
        }, "html");
    }
});