これはhtml私のコードです
<input type="text" name="country" id="country"/>
<input type="text" name="city" id="city"/>
これは私のjqueryコードです
$(document).ready(function() {
$('#country').keydown(function(){
$(this).autocomplete({
source: "get_country.php",
minLength: 0,
autoFocus: true,
select: function(event, ui)
{
}
});
});
var country = $("#country").val();
$('#city').keydown(function(){
$(this).autocomplete({
source: "get_city.php",
//type:"GET",
data : 'country='+country,
minLength: 0,
autoFocus: true,
select: function(event, ui)
{
}
});
});
});
これは私のコード get_city.php です
include_once('config.php');
if ( !isset($_REQUEST['term']) )
exit;
$country = $_POST['country'];
$rs = mysql_query('select city from xyz_table where country="$country" and city like "'. mysql_real_escape_string($_REQUEST['term']) .'%" order by city asc limit 0,10');
$data = array();
if ( $rs && mysql_num_rows($rs) )
{
while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) )
{
$data[] = array(
'value' => $row['city']
);
}
}
echo json_encode($data);
flush();
ここに問題通知の下に示されています:未定義のインデックス:G:\ xampp\htdocs\xyz\get_city.phpの6行目の国
ドイツ、イギリスなどのオートコンプリート検索で国を取得しました
国の下の都市をオートコンプリート検索したい (ドイツ/イギリスなど)
どうすれば解決できますか、何か提案をお願いします