如何在td中显示从数据库中检索数据而不刷新

how to show the retrieve data from database in td without refresh

本文关键字:数据 检索 刷新 数据库 td 显示      更新时间:2023-09-26

我有一个下拉框,它有两个客户端(例如:客户端,客户端),每个客户端表中有2000多个数据,当选择客户端时,我想从数据库中检索所有数据,并在前端显示,在不刷新的HTML表中,任何人都可以帮助我如何进行

我的下拉代码:

<select name="client" id="client" style="margin:-24px 0 0 1px;background-color:#E8E8E8;width:104px;position: absolute;"> 
   <option value="">Select Client</option>
<?php
$sql=mysql_query("select * from client_list");
$clientid=$_GET['clientid'];
while($row=mysql_fetch_assoc($sql))    
{
    if(strlen($_GET['clientid'])>0 && $_GET['clientid']==$row['clientid']){
    print' <option id="client" name="client" value="'.$row['clientid'].'" selected>'.$row['clientid'].' </option>';}
    else{
            print' <option id="client" name="client" value="'.$row['clientid'].'" >'.$row['clientid'].' </option>';
    }
       }
   ?>
</select>

Ajax

<script>
$(function() {    document.ready
    $("#client").on("change", function() {
        var ID=$(this).attr('id');
        var clientid=$("#client").val();
        $.ajax({
            type: "POST",
            data: {
                clientselect: $(this).val()
            },
            success: function(data) {
                $("#display").html(data);
                window.location = '?action=clientnetworkpricelist&clientid='+clientid+'';
                $("#flash").hide();
            }
        });
    });
});
</script>

AJAX调用中缺少URL:

$.ajax({
    url: "server.php",
    type: "post",
    data: {
        clientsel: $(this).val()
    },
    success: function(data) {
        $("#display").html(data);
        window.location = '?action=clientnetworkpricelist&clientid='+clientid+'';
        $("#flash").hide();
    }
});

server.php应该执行适当的数据库查询,并输出要放入display DIV的HTML。