点击按钮,我想发布电子邮件文本框的内容。当我点击登录按钮时没有任何反应。
我的文件目录:
Model /< - configuration.php在Model dir中。
查看/
控制器/
index.php< - 调用视图目录中的页眉,正文和页脚php类
<!-- Modal body -->
<div class="modal-body" style="padding:40px 50px;">
<form>
<div class="form-group">
<label for="usrname"><span class="glyphicon glyphicon-user"></span> Username</label>
<input type="text" class="form-control" name="email" id="email" placeholder="Enter email">
</div>
<div class="form-group">
<label for="psw"><span class="glyphicon glyphicon-eye-open"></span> Password</label>
<input type="text" class="form-control" id="password" placeholder="Enter password">
</div>
<div class="checkbox">
<label><input type="checkbox" value="" checked>Remember me</label>
</div>
<button type="button" name="loginButton" id="loginButton" name="loginButton" class="btn btn-success btn-block">Login</button>
</form>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<p>Not a member? <a href="View/registration.php">Sign Up</a></p>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$("#loginButton").click(function() {
$.ajax({
type: "POST",
url: "Model/configuration.php?action=login",
data: "email=" + $("#email").val(),
success: function (result) {
alert("result");
}
})
})
})
</script>
PHP文件
<?php
if($_GET['action'] == "login") {
print_r($_POST);
}
?>
答案 0 :(得分:2)
问题似乎是你的if条件有一个额外的括号。
试试这个:
<?php
if($_GET['action'] == "login") {
print_r($_POST);
}
?>
答案 1 :(得分:0)
$("#loginButton").click(function() {
$.ajax({
type: "POST",
url: "Model/configuration.php?action=login",
data: {email:$("#email").val()},
success: function (result) {
alert("result");
}
})
})
答案 2 :(得分:0)