Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在不刷新的情况下在td中显示从数据库检索的数据_Javascript_Php_Jquery_Html_Ajax - Fatal编程技术网

Javascript 如何在不刷新的情况下在td中显示从数据库检索的数据

Javascript 如何在不刷新的情况下在td中显示从数据库检索的数据,javascript,php,jquery,html,ajax,Javascript,Php,Jquery,Html,Ajax,我有一个下拉框,它有两个客户机(例如:客户机,客户机),每个客户机表中有2000多个数据,当选择客户机时,我想从数据库中检索所有数据,并在前端显示,在HTML表中不刷新,有人能帮我怎么做吗 我的下拉代码: <select name="client" id="client" style="margin:-24px 0 0 1px;background-color:#E8E8E8;width:104px;position: absolute;"> <option value

我有一个下拉框,它有两个客户机(例如:客户机,客户机),每个客户机表中有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>

选择客户端
阿贾克斯


$(函数(){document.ready
$(“#客户端”)。关于(“更改”,函数(){
var ID=$(this.attr('ID');
var clientid=$(“#client”).val();
$.ajax({
类型:“POST”,
数据:{
clientselect:$(this.val())
},
成功:功能(数据){
$(“#显示”).html(数据);
window.location='?action=clientnetworkpricelist&clientid='+clientid+'';
$(“#flash”).hide();
}
});
});
});

您在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
应执行适当的数据库查询,并输出要放入
显示
分区的HTML。

在函数开始时,
文档准备好了吗?这不是有效的Javascript语法。这应该是一个注释吗?你缺少AJAX服务器脚本的URL。你能为我写下代码吗?我们不是来为你写代码的,我们是来帮助你解决代码中的问题的。好的,你的意思是像这样的URL:xxx.com+“?action=clientnetworkpricelist&clientid='+clientid+',你能告诉我我做得对吗
$.ajax({
    url: "server.php",
    type: "post",
    data: {
        clientsel: $(this).val()
    },
    success: function(data) {
        $("#display").html(data);
        window.location = '?action=clientnetworkpricelist&clientid='+clientid+'';
        $("#flash").hide();
    }
});