码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-10-30 07:08:56      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:

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

 

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

标签:

原文地址:http://www.cnblogs.com/leigood/p/4922289.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!