AJAX-点击显示 出现表单内容

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="../jquery-1.11.2.min.js"></script>
<title>无标题文档</title>
</head>

<body>
<input  type="button" value="显示" id="btn"/>
<table  width="100%" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td>代号</td>
    <td>名称</td>
    <td>操作</td>
  </tr>
  <tbody id="tb">
  </tbody>
</table>
<script type="text/javascript">
$("#btn").click(function(){
    var bbb=$("#tb").html();
     $.ajax({
                     url:"nationchuli.php",
                     dataType:"TEXT",
                     success: function(data){
                     var hang = data.split("|");
                    
                         var str="";
                         for(var i=0;i<hang.length;i++)
                         { 
                             var lie =hang[i].split("^");
                             str=str+"<tr><td>"+lie[0]+"</td><td>"+lie[1]+"</td></tr>";
                         }
                    
                            $("#tb").html(str);
                     }
               })
               
    })
                 

</script>
</body>
</html>
<?php
include("../DBDA.class.php");
$db = new DBDA();
$sql="select * from nation";
echo $db->StrQuery($sql);

 

posted on 2016-11-11 10:14  奔跑的葛根  阅读(345)  评论(0编辑  收藏  举报

导航