为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我的代码运行之后加载不出来咧,在谷歌和IE浏览器都试过了

<!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="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>

        <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("http://www.imooc.com/data/sport.json",function(date){

                        $this.attr("disabled", "true");

                        $.each(date, function(index,sport){

                            if(index==3)

                            $("ul").append("<li>" + sport["name"] + "</li>");

                        });

                    });

                })

            });

        </script>

    </body>

</html>


正在回答

4 回答

奥,明白了,我也在纠结这个问题

mwkgq

0 回复 有任何疑惑可以回复我~

good,如果你能把代码再缩进一下就更完美了

ptlsdozeuzjchjeh 是恐惧,一边是淡然07 度政客:火龙果改名之后就代表我们"驯 我们已重回正轨克洛普英超5次KO穆帅!等于爵爷温格

0 回复 有任何疑惑可以回复我~

改这两个地方: <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js" type="text/javascript"></script>

加s:"https://www.imooc.com/data/sport.json"我的谷歌可以运行

1 回复 有任何疑惑可以回复我~
#1

qq_孔洁钰May_03759002

终于在评论找到解决方案了
2018-06-11 回复 有任何疑惑可以回复我~

第五行:<script src="https://www.imooc.com/static/lib/jquery/1.9.1/jquery.js"></script>

添加的代码位置   $.getJSON("https://www.imooc.com/data/sport.json",function(date){

所有的http改为https

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为什么我的代码运行之后加载不出来咧,在谷歌和IE浏览器都试过了

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信