dongxiai3003 2013-11-20 08:11
浏览 53

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

i having a drop down box, it have two client(ex:client,client),i have more then 2000 data in each client table ,when selecting client i want to retrieve all data from database and show it in front end that in HTML table with out refreshing can any one help me how to do that

my Dropdown code:

<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>
  • 写回答

1条回答 默认 最新

  • douding7189 2013-11-20 08:21
    关注

    You're missing the URL in the AJAX call:

    $.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 should perform the appropriate database query, and output the HTML that you want to be put into the display DIV.

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作