为什么没反应啊,上一节也是没反应。

来源:1-2 使用getJSON()方法异步加载JSON格式数据

晁东洋

2018-05-23 15:59

写进去代码点按钮也没用,上一节的内容也是。

写回答 关注

8回答

  • 慕的地8579676
    2019-04-05 18:21:46

    在if (index==3)之后加上大括号

  • name_yc
    2018-07-17 10:24:23

    我用的火狐浏览器,你可以尝试换换浏览器哦。

  • name_yc
    2018-07-17 10:21:35
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <title>使用getJSON()方法异步加载JSON格式数据</title>
            <script src="https://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script> //注意:路径写https:
            <link href="style.css" rel="stylesheet" type="text/css" />
        </head>
        
        <body>
            <div id="divtest">
                <div class="title">
                    <span class="fl">我最喜欢的一项运动</span> 
                    <span class="fr">
                        <input id="btnShow" type="button" value="加载" />
                    </span>
                </div>
                <ul></ul>
            </div>
            
            <script type="text/javascript">
                $(function () {
                    $("#btnShow").bind("click", function () {
                        var $this = $(this);
                        $.getJSON("https://www.imooc.com/data/sport.json", function (data) {    //注意:粘贴这块代码试试
                            $this.attr("disabled", "true");
                            $.each(data, function (index, sport) {
                                if(index==3)
                                $("ul").append("<li>" + sport["name"] + "</li>");
                            });
        
                        });
                    })
                });
            </script>
        </body>
    </html>

    可复制,可用。希望对你有帮助吧  (●'◡'●)

  • 慕斯卡6294805
    2018-07-10 18:30:18

    免费的果然差

  • AchillesTseng
    2018-06-05 15:02:13

    没反应是因为url的不确定是否正确,自己在本地写的可以

  • qq_哒哒_14
    2018-05-31 16:02:22

    我是在Hbuiler里面重新写了一遍  没问题   在这里没反应 

  • Chai_陌路
    2018-05-30 14:44:53

    把页面中的两个http都改成https

  • 慕尼黑7945176
    2018-05-23 17:58:50

    我也是

jQuery基础(五)一Ajax应用与常用插件

如何用jquery实现ajax应用,加入学习,有效提高前端开发速度

69095 学习 · 400 问题

查看课程

相似问题