夺命雷公狗jquery---53--jQuery里的ajax的底层实现POST请求

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script src="js/jquery.js"></script>
        <script>
            $(function(){
                $('#btnok').bind('click',function(){
                    var username = $('#username').val();
                    //发送ajax请求
                    $.ajax({
                        type:'post',
                        url:'ajax2.php',
                        data:'username='+username,
                        success:function(msg){
                            alert(msg);
                        }
                    });
                });
            });
        </script>
    </head>
    <body>
        <input type="text" id="username" />
        <hr />
        <input type="button" id="btnok" value="OK" />
    </body>
</html>

 

 

 

php里面的代码如下:

 

 

<?php
    $username = $_POST['username'];
    echo "hello ".$username;

 

posted @ 2015-10-30 06:19  夺命雷公狗  阅读(271)  评论(0编辑  收藏  举报