Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4621340
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:41:14+00:00 2026-05-22T02:41:14+00:00

I have an auto-complete input where visitors enter a location and it provides suggestions

  • 0

I have an auto-complete input where visitors enter a location and it provides suggestions while you type. I’m using the Geonames web server for this.

I’m trying to return an exception message if an error occurs on the Geonames web server. For example if I exceed my web server request limit I want the script to send me an email alert.

The exception message returned is JSON.

This is part of the script with the error() function. I deliberately made a typo in the username parameter in data to get an error but no alert appears.

$(function() {
        $( "#city" ).autocomplete({
            source: function( request, response ) {
                $.ajax({
                    url: "http://api.geonames.org/searchJSON",
                    dataType: "jsonp",
                    data: {
                        q: request.term,
                        countryBias: "US",
                        featureClass: "P",
                        style: "full",
                        maxRows: 10,
                        ussername: "demo",
                        operator: "OR"
                    },
                    success: function( data ) {
                        response( $.map( data.geonames, function( item ) {                                                           
                            return {
                                label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
                                value: item.name,
                                saved_country: item.countryName,
                                saved_state: item.adminName1,
                                saved_city: item.name,
                                saved_zipcode: item.postalcode,
                                saved_latitude: item.lat,
                                saved_longitude: item.lng,                                                                                              
                            }
                        }));  
                    },  
                    error: function( data ) {
                        response( $.map( data.geonames, function( item ) {                                                           
                            return {
                                request_status: item.status                             
                            }
                            alert("Error msg!");
                        }));  
                    },                                              
                });             
            },
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:41:15+00:00Added an answer on May 22, 2026 at 2:41 am

    Geonames will return this error information in the success hundler, not the error handler. So you’d have to ask inside your success function:

    success: function( data ) {
        if(typeof(data.status) != 'undefined'){ //It means there was an error
           var errorObject = data;
           //Now you have access to errorObject.status, errorObject.status.message and so on
           //Do something with your error object
           return; //Avoid execution of the rest of the code of this function
        } //Can add an else here if you want
        response( $.map( data.geonames, function(item){
          ...
    
    }
    

    Hope this helps. Cheers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Youtube API, I'd like to have a search auto-complete feature, just like
I have a form with a input box that I want to auto-complete with
I have an auto-complete input, works great .. When I fill the content through
I've created a simple auto-complete control using JQuery UI. I have a default value
Any nice suggestions on auto complete location searches, that integrate with something like Google
I am using jQuery auto-complete. I have download this script from http://code.google.com/p/jquery-autocomplete/ . I
I am newbie to php.I have coded auto-complete text box using php,and i have
I am building a web app that will use an auto-complete/suggestions for the end
I have implemented the auto complete functionality using the Ajax.autocompleter function of the Scriptaculous
I have implemented an auto complete event using Jquery , and it works fine,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.