Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 地理名称例外_Jquery_Api_Geonames - Fatal编程技术网

Jquery 地理名称例外

Jquery 地理名称例外,jquery,api,geonames,Jquery,Api,Geonames,我正在使用Geonames web服务在我的网站上注册。如果发生错误,我想给自己发送一封包含错误的电子邮件。Geonames返回异常,但我不确定如何显示它们 我在Jquery中使用Geonames来自动完成用户输入的位置 $( "#location" ).autocomplete({ source: function( request, response ) { $.ajax({ url: "http

我正在使用Geonames web服务在我的网站上注册。如果发生错误,我想给自己发送一封包含错误的电子邮件。Geonames返回异常,但我不确定如何显示它们

我在Jquery中使用Geonames来自动完成用户输入的位置

$( "#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
选项。希望这是有帮助的