Jquery 地理名称例外
我正在使用Geonames web服务在我的网站上注册。如果发生错误,我想给自己发送一封包含错误的电子邮件。Geonames返回异常,但我不确定如何显示它们 我在Jquery中使用Geonames来自动完成用户输入的位置Jquery 地理名称例外,jquery,api,geonames,Jquery,Api,Geonames,我正在使用Geonames web服务在我的网站上注册。如果发生错误,我想给自己发送一封包含错误的电子邮件。Geonames返回异常,但我不确定如何显示它们 我在Jquery中使用Geonames来自动完成用户输入的位置 $( "#location" ).autocomplete({ source: function( request, response ) { $.ajax({ url: "http
$( "#location" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "http://ws.geonames.org/searchJSON",
dataType: "jsonp",
data: {
q: request.term,
featureClass: "P",
style: "full",
maxRows: 10
},
success: function( data ) {
response( $.map( data.geonames, function( item ) {
return {
label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
value: item.name,
latitude: item.lat,
longitude: item.lng,
status: item.status
}
}));
在success函数中,最后一个参数status应该返回请求的状态。我将其附加到div,但没有显示任何内容。请帮帮我。。我不确定我做错了什么。我对这一个玩了很多次,我觉得你想得太多了。在我看来,JSON响应将包含
status
属性的唯一情况是HTTP响应不是200
例如,当您从服务器上为过载的服务获取503时,该成功函数实际上从未运行过。据我所知,您需要添加error:function(data){…}
才能访问status
选项。希望这是有帮助的