jQuery中的ajax的使用

    技术2022-05-20  30

    这个程序主要是由三个页面组成 jquery.js  1.html  testget.php

     

     

    主要的程序是写在 1.html中通过一个button的按钮,触发一个时间,通过ajax方法调用testget.php并将返回值追加到页面上。

     

    ------------------------------------------------------------------------------------------------------------------------------------------

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>jQuery Playground</title>

    <link title="green" media="screen" href="css/green.css" type="text/css" rel="stylesheet" />

    <script type="text/javascript" src="js/jquery.js"></script>

    <script type="text/javascript">

    $(document).ready(function(){ 

    $("#test").click(function(){

    var purl='testget.php?namer=123';

           $.ajax({

        url: purl,

            type: 'POST',

            dataType: 'html',

            timeout: 61000,

            error: function(){

            alert('Please check web status');

            },

            success: function(data){

           

            $("#display").append("<b>返回值为</b> " + data + "<br/>");

            }

    });

    }); 

    });

    </script>

    </head>

    <body>

    <div id="wrapper">

    <h1>jQuery Playground</h1>

    <ul id="nav">

       <li><a class="current" href="index.html"> </a></li>

       <li><a href="#"></a></li>

    </ul>

    <div id="content">

    <input type="button" id="test" value="onclick" />

    <h2>result</h2>

    <div id="display"></div> 

    </div>

    <div id="foot">Powered By Dennis Ji.</div>

    </div>

    </body>

    </html>

    ---------------------------------------------------------------------------------------------------------------------------------------- <?php $name = $_GET['name']; //echo "Hello " . $name . "!"; echo '111111111111111111111111111111111111111111111111111'; ?>


    最新回复(0)