I have this bit of 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>
and I've got this bit of JavaScript:
$("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");
}
});
On the server-side I have my own PHP API but this doesn't matter because strangely enough even at the top of the index.php file $_SERVER['REQUEST_METHOD']
returns "GET" and var_dump($_REQUEST)
returns no data at all.
I haven't encountered this problem on any of my other websites (which are using the same PHP CMS I've developed) before so I assume for now I'm doing something wrong in my JavaScript code, but I can't discover the problem.