亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

???? ?? ?? ?? ?? ??? ?? PHP ??(3)

jQuery? ?? ? ?? ??? ?????. ??? Ajax? ?? ?????? ?? ??? ?? ???? ????. ?? ??? ???? ?? ???? ???? ?? ??? ???? ?? 1? ??? ????.

?? ???? ??? ? $.ajax()? ?? ????? filelist.php? GET ??? Ajax ??? ????. filelist.php? ????? ???? ??? json ???? ???? $.each? ?? ?????. () json ??? ??? ????, html ???? ????, ?? ???? ul.filelist? ???? ???? ?? ??? ?????.

?? ??? ???? ?????? ???? ??? ?? ??? ?? ???? live()? ?? ???? ???? ??? ?????.

<script type="text/javascript">
$(function(){
   $.ajax({  //異步請求
      type: 'GET',
      url: 'filelist.php',
      dataType: 'json',
      cache: false,
      beforeSend: function(){
         $(".filelist").html("<li class='load'>正在載入...</li>");
      },
      success: function(json){
         if(json){
            var li = '';
            $.each(json,function(index,array){
               li = li + '<li><a href="download.php?id='+array['id']+'">'+array['file']+'<span class="downcount" title="下載次數(shù)">'
               +array['downloads']+'</span><span class="download">點擊下載</span></a></li>';
              });
            $(".filelist").html(li);
         }
      }
   });
   $('ul.filelist a').live('click',function(){
      var count = $('.downcount',this);
      count.text(parseInt(count.text())+1);
   });
});
</script>

Notes:

ajax? ??? ????

1.type

Type: String

???: "GET"). ?? ??("POST" ?? "GET"), ???? "GET"???.

2.url

??: ???

???: ?? ??? ??. ??? ?? ?????.

3.dataType

Type: String

???? ??? ??? ???? ??? ?????. ??? "json"???. JSON ???? ?????.

4.cache

??: Boolean

???: true, dataType? script?? jsonp? ?? ???? false???. ? ???? ???? ???? false? ?????.

5.beforeSend

Type: Function

??? ??? ?? XMLHttpRequest ??? ??? ? ?? ?????.

XMLHttpRequest ??? ??? ???????.

6.success

Type: Function

?? ?? ? ?? ?????.

live() ???? ?? ??? ??? ???? ??? ??? ???? ??? ???? ??? ? ??? ??? ?????.

?? ? ?? ?? ?? ??? ??? ????? ???? Ajax ?????. ?? ????? ???? ?? PHP? ??? ??? ????.

jQuery ? ajax ??? ? ??? ??? ipnx.cn?? ?? ????? ?????.

???? ??
||
<script type="text/javascript"> $(function(){ $.ajax({ //異步請求 type: 'GET', url: 'filelist.php', dataType: 'json', cache: false, beforeSend: function(){ $(".filelist").html("<li class='load'>正在載入...</li>"); }, success: function(json){ if(json){ var li = ''; $.each(json,function(index,array){ li = li + '<li><a href="download.php?id='+array['id']+'">'+array['file']+'<span class="downcount" title="下載次數(shù)">' +array['downloads']+'</span><span class="download">點擊下載</span></a></li>'; }); $(".filelist").html(li); } } }); $('ul.filelist a').live('click',function(){ var count = $('.downcount',this); count.text( parseInt(count.text())+1); }); }); </script>