1

现在我通过刷新页面显示数据,但我想在不刷新页面的情况下显示数据,这 window.location = '?action=suppliernetwork&supplier_id='+supplier_id+''; 是刷新页面的原因任何人都指导我如何在刷新页面的情况下执行此操作。谢谢

HTML

<select name="supplierselect" id="supplierselect" style="margin:0px 0px 0px 0px;background-color:#C2FFC2;width:125px;"> 
    <option>--Select--</option> 
    <?php
$dbHost = 'localhost'; // usually localhost
$dbUsername = '';
$dbPassword = '';
$dbDatabase = '';
$db = mysql_connect($dbHost, $dbUsername, $dbPassword) or die ("Unable to connect to Database Server.");
mysql_select_db ($dbDatabase, $db) or die ("Could not select database.");

$sql=mysql_query("select * from supplier");

while($row=mysql_fetch_array($sql))
{
 ?>
    <option id="supplierselect" value="<?php echo $row['supplier_id']; ?>"><?php echo $row['supplier_id']; ?></option>
    <?php } ?>


</select>

阿贾克斯:

$(function() {  //  document.ready
    $("#supplierselect").on("change", function() {
        //var ID=$(this).attr('id');
        var supplier_id=$("#supplierselect").val();
        $.ajax({
            url: "suppliernetwork/select.php",
            type: "POST",
            data: {
                supplierselect: $(this).val()
            },
            success: function(data) {
                $("#display").html(data);
                window.location = '?action=suppliernetwork&supplier_id='+supplier_id+'';
                $("#flash").hide();
            }
        });
    });
});
4

0 回答 0