1

我有一个下拉框,我在其中显示来自数据库的数据,当我选择任何数据时,它不会在选择时快速刷新页面,而是在 5 秒后刷新页面,谁能帮我解决这个问题,下面是我的代码:

Javascript:

$(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();
            }
        });
    });
});

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> 
4

2 回答 2

4

正如kitty 所说,延迟是从数据库中获取数据所需的时间。您需要找到一种方法来加快数据库响应。

可能有用的链接: http ://www.peachpit.com/articles/article.aspx?p=1851233

于 2013-11-14T10:09:36.830 回答
2

实现对服务器的 ajax 请求需要时间,这取决于服务器端代码响应 + 网络传输等所需的时间。

于 2013-11-14T10:11:00.330 回答