美文网首页
5.使用jQuery使用ajax

5.使用jQuery使用ajax

作者: Ringo_ | 来源:发表于2019-08-27 21:26 被阅读0次
<!DOCTYPE html>
<html>

    <head>
        <meta charset="utf-8">
        <title>菜鸟教程(runoob.com)</title>
        <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
        </script>
        <script>
            $(document).ready(function() {
                //alert("hi");
                $("button").click(function() {
                    $.get("content/helloajax.txt", function(data, status){
                        alert(status);
                        $("#cityname").html(data);
                    });
                });
            });
        </script>
    </head>

    <body>
        <h2 id="cityname"></h2>
        <!--<p id="updatetime"></p>
        <p id="wendu"></p>-->
        <button>点我</button>
    </body>

</html>

因为并没有学jQuery,所以这里只是对照着jQuery的文档写了一个小的案例。

相关文章

网友评论

      本文标题:5.使用jQuery使用ajax

      本文链接:https://www.haomeiwen.com/subject/gyiyectx.html