本文介绍了有没有自动填充城市样本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好...我一直在寻找使用jquery列出所有可能城市的任何示例或任何代码...但是我找不到提供此解决方案的简单示例...我有此代码我只是复制到一个网站上
Hello guys... i''ve been looking for any samples or any code that will lists all the possible cities using jquery... but i cant find a simple sample that gives this solution... i have this code that i just copied on one site
$( "#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
}
}));
}
});
},
minLength: 2,
select: function( event, ui ) {
log( ui.item ?
"Selected: " + ui.item.label :
"Nothing selected, input was " + this.value);
},
open: function() {
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
}
});
但是当我尝试运行它时,出现一个错误,提示我
but when i try to run it, gives me an error saying
404 Not Found - http://mysite.com/_subfolder/undefined?query=p"
不能真正解决问题...任何人都可以给我答案我的问题...在此先感谢
cant really solve the problem... can anyone give me an answer to my problem please... thanks in advance
推荐答案
这篇关于有没有自动填充城市样本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!