Blogger Information
Blog 65
fans 3
comment 4
visits 67808
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
初始AJAX-post
无耻的鱼
Original
777 people have browsed it

ajax数据交互,常见的get、post、

2.png


实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ajax</title>
    <style type="text/css">
        div{
            width: 200px;
            margin: auto;
        }
    </style>
</head>
<body>
<div>
            <h2>用户验证</h2>

                <label for="email">邮箱:</label>
                <input type="email" name="email" id="email"> <br>

                <label for="password">密码:</label>
                <input type="password" name="password" id="password"> <br>

                <button>验证</button> 
</div>
</body>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript">

    $('button').click (function(){

            $.post(
                'post.php?m=login',
                {           
                    "email": $('#email').val(),
                    "password": $('#password').val()        
                }, 
                function(data){
                    if (data == '1') {
                        alert('你好,你的账号密码正确')
                    } else {
                        alert('你好,你的账号密码不正确')  
                    }
                })

        
        //禁用默认提交
        return false
    })

            
</script>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


0410-1.png0410-2.png


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post