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 have implemented the auto complete functionality using the Ajax.autocompleter function of the Scriptaculous
Guys i am very new to jQuery. I have started using the auto complete
Any nice suggestions on auto complete location searches, that integrate with something like Google
We have an auto-complete list that's populated when an you send an email to
I have a question about how to collaborate auto complete with UI dialog: There
I'm working on a project where I need a jQuery auto-complete for Cities. What
Lets say I have a FirstName > MiddleName > LastName hierarchy (~10k rows, for
I'm creating my own recipe box using php/mysql and one part I'm stuck on
My problem is, that the browsers' (IE&FF) autocomplete does not work for my login
Lets say we need to select two sets from a table: Things var GradeA

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.