(066)jquery_异步_getJSON

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
  <head>
    <title>ajax_getjson.html</title>
    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
    <style type="text/css">
        #divtest
        {
            width: 282px;
        }
        #divtest .title
        {
            padding: 8px;
            background-color:Blue;
            color:#fff;
            height: 23px;
            line-height: 23px;
            font-size: 15px;
            font-weight: bold;
        }
        ul
        {
            float: left;
            width: 280px;
            padding: 5px 0px;
            margin: 0px;
            font-size: 14px;
            list-style-type: none;
        }
        ul li
        {
            float: left;
            width: 280px;
            height: 23px;
            line-height: 23px;
            padding: 3px 8px;
        }
        .fl
        {
            float: left;
        }
        .fr
        {
            float: right;
        }
    </style>
    <script type="text/javascript" src="../js/jquery/jquery190.js"></script>
    <script type="text/javascript">
        $(function(){
            $("#btnShow").bind("click",function(){
                var $this = $(this);
                $.getJSON("../temp/sport.json",function(data){
                    $this.attr("disabled","true");
                    $.each(data,function(index,element){
                        $("ul").append("<li>" + element["name"] + "</li>");
                    });
                });
            });
        });
    </script>
  </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>
  </body>
</html>

 

posted @ 2015-01-04 11:15  雪中飞雁  阅读(64)  评论(0)    收藏  举报