Php 带有附加参数的jQuery自动完成

Php 带有附加参数的jQuery自动完成,php,jquery,ajax,autocomplete,Php,Jquery,Ajax,Autocomplete,我在做一个自动完成函数,我在传递参数,但它不起作用 $("#destination-region").autocomplete({ source: "/interface/regions_datalist.php?idCountry="+$("#destination-country-id").val(), minLength: 2, select: function (event, ui) { $("#destination-re


我在做一个自动完成函数,我在传递参数,但它不起作用

$("#destination-region").autocomplete({
    source: "/interface/regions_datalist.php?idCountry="+$("#destination-country-id").val(),
    minLength: 2,
    select:
        function (event, ui) {
            $("#destination-region-id").val(ui.item.idRegion);
                $("#destination-country-preview")
                    .html('<i class="fa fa-map-pin" aria-hidden="true"></i> ' + $("#destination-country").val() + " - " + $("#destination-region").val());
        }
});
$(“#目的地区域”)。自动完成({
来源:“/interface/regions_datalist.php?idCountry=“+$(“#目的地国家id”).val(),
最小长度:2,
选择:
功能(事件、用户界面){
$(“#目的地区域id”).val(ui.item.idRegion);
$(“#目的地国预览”)
.html(“”+$(“#目的地国家”).val()+“-”+$(“#目的地地区”).val());
}
});
这是我的php代码(我已经用这个链接尝试过了:www.site.ext/interface/regions\u datalist.php?idCountry=1&term=la),它可以工作

<?php
include_once "../core/adminAutoloader.php";

$idCountry = $_GET["idCountry"];
$name = $_GET["term"];
$regionFacade = new regionFacade();
$regions = $regionFacade->findRegionByNameAndCountry($idCountry,$name);
$regionsArray = array();
while($region = $regions->fetch(PDO::FETCH_ASSOC)) {
    $tmpRegion["idRegion"] = $region["idRegion"];
    $tmpRegion["value"] = $region["name"];
    $tmpRegion["label"] = $region["name"];
    array_push($regionsArray,$tmpRegion);
}
echo json_encode($regionsArray);

它不起作用了到底是怎么回事?开发人员控制台中有错误吗?您需要将要获取的对象转换回jQueryUI期望的格式的数组中@罗曼:我照你说的做。事实上,相同的脚本不会有额外的参数!所以,如果您只通过ww.site.ext/interface/regions\u datalist.php,它就可以正常工作了?在json_编码之前,是否可以使用var_dump regions_数组(带参数和不带参数)?