首页 > 代码库 > Jquary 和Ajax实现简单的异步请求

Jquary 和Ajax实现简单的异步请求

代码:

<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Ajax测试</title>
     <link   rel="stylesheet" href="../demo1/bootstrap/css/bootstrap.css">
  <script src="jq/jQueryDownload/jquery.min.js"></script>
</head>
<body>
<button  id="sb"  type="button" class="btn btn-info">信息按钮</button>

<script>
 $(document).ready(function(){
        $("#sb").click(function(){
            $.post("http://localhost/demo2/test1.php",{
                        name:"印第安老斑鸠",
                        url:"http://www.laobanjiu.com"
                    },
                    function(data,status){
                        alert("数据: \n" + data + "\n状态: " + status);
                    });
        });
    });
</script>
</body>
</html>

 

Jquary 和Ajax实现简单的异步请求