English 中文(简体)
地名例外
原标题:geonames exception

我正在利用地名网络服务在我的网站上进行登记。 如果出现错误,我就希望发出一份带有错误的电子邮件。 www.geonames.org 但我不敢肯定如何展示。

在用户进入时,使用吉克里的地名进行汽车结业地点。

$( "#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
                            }
                        }));  

In the success function the last parameter status should return the status of the request. I appended that to a div but nothing appears. Please help me.. I m not sure what I m doing wrong.

最佳回答

I played around quite a bit with this one and I think you re overthinking it. It looks to me like the only situation in which your JSON response is going to contain a status attribute is when the HTTP response is not 200.

例如,当你从服务器获得503台服务超负荷时,这一成功功能实际上从未运行。 从我能告诉大家的角度来看,需要添加<代码>error:功能(数据){......},以便能够查阅<代码>status<>/code>。 希望是有益的!

问题回答

暂无回答




相关问题
C# Networking API s [closed]

Lately I ve been looking for a good networking API i could possibly use and/or reference some of the code within, but i have mere luck searching for some on Google/Bing. Hopefully somebody here has ...

getting XML from other domain using ASP.NET

I m fairly new to ASP.NET. And I was wondering how I could go about getting xml from a site (Kuler s API in this case), and then post the result using AJAX? So what I want here, is to be able to do a ...

Most appropriate API for URL shortening service

I ve just finished an online service for shortening URLs (in php5 with Zend Framework); you can enter an URL and you get an short URL (like tinyurl and such sites). I m thinking about the API for ...

UML Diagram to Model API

I need to create a diagram to document a RESTFul API that build, which UML diagram should I use? Thanks in advance,

How best to expose Rails methods via an API?

Let s say I have a model foo, and my model has a publish! method that changes a few properties on that model and potentially a few others too. Now, the Rails way suggests that I expose my model over ...

简讯

我是否可以使用某些软件来建立简便的航天国家服务器,最好是在 Java? 所有我都希望我的航天国家服务机在任何要求中都用同样的IP地址来回答。

About paypal express checkout api

In this picture,there are 3 main steps:SetExpressCheckout,GetExpressCheckoutDetails and DoExpressCheckoutDetails,I m now sure SetExpressCheckout is to be called by myself,what about ...

热门标签