• 技术文章 >web前端 >js教程

    jQuery一个ajax实例

    一个新手一个新手2017-10-11 09:07:16原创542
    前提:电脑上已经安装了AppServ

    代码如下:

    第一个页面,只写HTML代码:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>第一个ajax</title>
    </head>
    <body>
    <p class="comment">
        <h6>zhangsan:</h6>
        <p class="para">soft</p>
    </p>
    <p class="comment">
        <h6>李四:</h6>
        <p class="para">板凳</p>
    </p>
    <p class="comment">
        <h6>王五:</h6>
        <p class="para">地板</p>
    </p>
    
    </p>
    <script src="../libs/jquery.js"></script>
    </body>
    </html>

    第二个页面,写jQuery代码

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>test</title>
    </head>
    <body>
    <input type="button" id="send" value="Ajax获取">
    <p class="comment">已有评论:</p>
    <p id="resText"></p>
    <script src="../libs/jquery.js"></script>
    <script>
        $(function () {
            $("#send").click(function () {
               /* $("#resText").load("firstajax.html");   //将firstajax页面整个内容加在id为restext中*/
               /* $("#resText").load("firstajax.html .para");     //将firstajax页面中class为para的内容加在restext中*/
            });
        });
    </script>
    </body>
    </html>

    以上就是jQuery一个ajax实例的详细内容,更多请关注php中文网其它相关文章!

    声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理
    专题推荐:jQuery ajax 实例
    上一篇:JavaScript中关于数组定义的几种方法分享 下一篇:window.onload的使用方法
    大前端线上培训班

    相关文章推荐

    • javascript怎么设置p的值• javascript如何获取当前方法名• JavaScript中数组如何遍历• 焦点在javascript中是什么• javascript怎么检测变量是否存在

    全部评论我要评论

  • 取消发布评论发送
  • 1/1

    PHP中文网