Arrays 关于Autocomplete小部件中数组的ajax指令

Arrays 关于Autocomplete小部件中数组的ajax指令,arrays,jquery,firebug,jquery-autocomplete,Arrays,Jquery,Firebug,Jquery Autocomplete,我在source:选项中有一个使用geonames.org cities的Autocomplete,并希望操作结果中的一些数组。我有一个“硬编码”的测试版本正在运行,但在处理数组变量以将其转换为有用的内容时遇到了困难 问题的一个简短陈述是,我无法让警报语句输出可读字符串。我得到[对象,对象]类型的输出。我需要数组中的可读字符串,以便其他代码(未显示)工作。但其他问题是:Firebug控制台输出没有出现,控制台给了我以下错误声明-错误:拒绝访问jQuery第2行的属性“item.autocompl

我在source:选项中有一个使用geonames.org cities的Autocomplete,并希望操作结果中的一些数组。我有一个“硬编码”的测试版本正在运行,但在处理数组变量以将其转换为有用的内容时遇到了困难

问题的一个简短陈述是,我无法让警报语句输出可读字符串。我得到[对象,对象]类型的输出。我需要数组中的可读字符串,以便其他代码(未显示)工作。但其他问题是:Firebug控制台输出没有出现,控制台给了我以下错误声明-错误:拒绝访问jQuery第2行的属性“item.autocomplete”的权限。硬编码测试不会发生这种情况。这是我第一次使用.grep,我对.map感到不舒服,所以我很确定这三个部分的问题是数组操作

这里有一些相关的代码。所有变量都已声明,但我不会在下面显示所有声明

citiesWithBoroughs = //a global array variable, populated in a prior select: option

source: function (request, response){
    $.ajax({
        success: function ( data ){
            var geonamesResponse=$.map(data.geonames, function (item){
                return {
                    label: item.name //and others
                }
            }
            alert(citiesWithBoroughs + "," + citiesWithBoroughs.length + "|cWB2" ); //displays correct info
            var noBoroughs=$.grep( geonamesResponse, function ( item, i ) {
                for (var i=0; i < citiesWithBoroughs.length; i++ )
                if( item.label === citiesWithBoroughs[i] ){ //compare  geonamesResponse to each citiesWithBoroughs
                    console.log(citiesWithBoroughs[i]); //nothing in Console
                    return false; //drop any matches out of the geonamesResponse array
                }
                noBoroughs = $.map( data.geonames, function (item){ return item.label; });
                    console.log(noBoroughs); //nothing appears in Console
                return true;        
            });
        alert(noBoroughs.length + "," + citiesWithBoroughs.length + "," + geonamesResponse.length + "|3lengths" ); //correct info
        alert(noBoroughs + "|nB" ); //in test, shows correct number of [object,Object]  but no data
        if( noBoroughs.length != geonamesResponse.length ){
            var dropdownsCityWithBoroughs = $.grep( geonamesResponse, function ( item, i ) {
                for (var i=0; i<citiesWithBoroughs.length; i++ )
                if(item.label === citiesWithBoroughs[i]){return false;}
                return true;
            }, true )//true inverts grep to return the has-Boroughs city in the dropdown
            alert(dropdownsCityWithBoroughs + "|dCWB"); //contains object, Object, but shows no data 
            }                
        }            
    }
}
citiesWithBoroughs=//一个全局数组变量,在前面的select:选项中填充
来源:功能(请求、响应){
$.ajax({
成功:功能(数据){
var geonamesResponse=$.map(data.geonames,函数(项){
返回{
标签:item.name//和其他
}
}
警报(citiesWithBoroughs+”,“+citiesWithBoroughs.length+”;//显示正确的信息
var noBoroughs=$.grep(地理名称响应,函数(项,i){
对于(变量i=0;i对于(var i=0;i而言,我的问题的简短陈述是我无法读取包含数组的警报的输出。结果表明,JSON.stringify()修复了这一问题。其他问题,如Console.log语句没有显示continue,但我可以在警报工作时处理这个神秘的问题