我如何通过 ajax 在此函数上发送 2 个或更多 ID


how can i send 2 id or more on this function by ajax

我如何通过 ajax 在此函数上发送 2 个或更多 id

function advcust(id) {                      
    $.ajax ({
           url: "php_filter.php?cust=advcust",
           type: "GET",
           data: {CustStatus:id},
           success: function(data){
                    $("#return").html(data)
                    }
        })
}

在这里我只能发送一个ID但我需要发送 2 个或更多 ID

我有两种输入类型来搜索两个单词我可以在 AJAX 上发送 2 个 ID 吗

function advcust(id, anotherID)
{
  $.ajax ({
       url: "php_filter.php?cust=advcust",
       type: "GET",
       data: {CustStatus:id,SomeOverVar:anotherID},
       success: function(data){
                $("#return").html(data)
                }
    })
}
function advcust(ids) {
    $.ajax ({
        url: "php_filter.php?cust=advcust",
        type: "GET",
        data: {CustStatus: ids},
        success: function(data){
            $("#return").html(data);
        }
    });
}
var ids = [];
ids.push(id1);
ids.push(id2);
advcust(ids);

然后,您可以在 PHP 中以数组形式访问客户 ID:

<?php
$customerIds = $_GET['CustStatus'];
foreach ($customerIds as $customerId) {
    // do something...
}