weixin_33698043 2017-11-15 10:54 采纳率: 0%
浏览 21

AJAX POST数据未发送

On button click, i want to post the contents of the email text box. When i click the login button nothing happens.

My File dir:

Model/ <-- configuration.php is inside Model dir.

View/

Controller/

index.php <-- calls the header, body, and footer php classes that are in the view dir

                    <!-- 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 file

<?php

if($_GET['action'] == "login") {
    print_r($_POST);
}

?>
  • 写回答

3条回答 默认 最新

  • weixin_33734785 2017-11-15 11:03
    关注
    $("#loginButton").click(function() {
                $.ajax({
                    type: "POST",
                    url: "Model/configuration.php?action=login",
                    data: {email:$("#email").val()},
                    success: function (result) {
                        alert("result");
                    }
                })
            })
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀