Javascript Jquery Ui自动完成仅从一个国家/地区获取城市

Javascript Jquery Ui自动完成仅从一个国家/地区获取城市,javascript,jquery,html,css,jquery-ui,Javascript,Jquery,Html,Css,Jquery Ui,我在那里使用jquery Ui auto complete,我希望下拉菜单只显示(触发)单个国家(如孟加拉国)的城市。我怎么能得到这个 以下是JavaScript方法: $(function() { $( ".city" ).autocomplete({ source: function( request, response ) { $.ajax({ url: "http://ws.geonames.org/sear

我在那里使用jquery Ui auto complete,我希望下拉菜单只显示(触发)单个国家(如孟加拉国)的城市。我怎么能得到这个

以下是JavaScript方法:

$(function() {
    $( ".city" ).autocomplete({
        source: function( request, response ) {
            $.ajax({
                url: "http://ws.geonames.org/searchJSON",
                dataType: "jsonp",
                data: {
                    featureClass: "P",
                    style: "full",
                    maxRows: 12,
                    name_startsWith: request.term
                },
                success: function( data ) {
                    response( $.map( data.geonames, function( item ) {
                        return {
                            label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
                            value: item.name
                        }
                    }));
                }
            });
        }
    });
});

谢谢。

您需要在url中传递国家代码。e、 g.“'

更新的js:

$(function() {
        $( ".city" ).autocomplete({
            source: function( request, response ) {
                $.ajax({
                    url: "http://ws.geonames.org/searchJSON?&country=BD",
                    dataType: "jsonp",
                    data: {
                        featureClass: "P",
                        style: "full",
                        maxRows: 12,
                        name_startsWith: request.term
                    },
                    success: function( data ) {
                        response( $.map( data.geonames, function( item ) {
                            return {
                                label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
                                value: item.name
                            }
                        }));
                    }
                });
            }
        });
    });

又好又快的回答!!