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

  • Home
  • SEARCH
  • 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 8025397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:09:09+00:00 2026-06-04T23:09:09+00:00

Hey i am using Ajax Autocomplete for Jquery by Tomas (http://www.devbridge.com/projects/autocomplete/jquery/) in my GAE

  • 0

Hey i am using Ajax Autocomplete for Jquery by Tomas (http://www.devbridge.com/projects/autocomplete/jquery/) in my GAE application. I have a City search module where a person keys in a city and the list of city names to choose from appear in a dropdown list. I am returning a json response as required by the Autocomplete Library. I am able to display the list of cities in the drop down however i want the user to be redirected to a specific url as he selects an option from the list. i am also returning a data object which is an optional parameter in the json results. So now there are three things that i am returning.

1. 'query': 'Ade'
2. 'suggestions': ['Adelaide', 'Adelaide Hills', 'Adelia Maria']
3. 'data': [{'Adelaide': '/Oceania/Australia/Adelaide'},{'Adelaide Hills':'/Oceania/Australia/Adelaide Hills'},{'Adelia Maria':'/Oceania/Australia/Adelia Maria'}]

Here is the code where i am sending the json results:

class SearchCity(TemplateHandler):
  def get(self):
    results, data, url = [], [], ''
    word = self.request.get('query')
    search = models.City.all().filter('name >=', word.capitalize()).filter('name <', word.capitalize()     + u'\ufffd')
    for res in search:
      url = '/' + res.country.continent.name + '/' + res.country.url_name + '/' + res.name + '/'
      results.append(res.name)
      data.append({res.name:url})
    json_results = {
     'query' : word, 
     'suggestions' : results,
     'data': data
    }
  self.response.out.write(json.dumps(json_results))

Here’s the Javascript where i am trying to trigger the Autocomplete function:

<script type="text/javascript">
  //<![CDATA[
   var a = $('#search-city').autocomplete({
     serviceUrl:'/search_city',
     delimiter: /(,|;)\s*/, // regex or character
     maxHeight:140,
     width:170,
     zIndex: 9999,
     deferRequestBy: 0, //miliseconds
     noCache: false, //default is false, set to true to disable caching
   });
  //]]>
</script>

Now according to the Author of the plugin we can use something like this for a call back function:

// callback function:
onSelect: function(value, data){ alert('You selected: ' + value + ', ' + data); },

Questions:

1.) how do i access the the value of url in the dictionary that has the key which user has selected and redirect the user to that url ?

2.) if i just pass the list of urls in the ‘data’ object would i be able to link the right Name to the right url ?

3.) Also, is there a way that i can Show ‘No Matches Found’ if there are no results in the suggestions list ?

  • 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-06-04T23:09:11+00:00Added an answer on June 4, 2026 at 11:09 pm

    Sorry it was as easy as changing:

    data.append({res.name:url})
    

    to

    data.append(url)
    

    and adding the following to the JS configuration :

    onSelect: function(value, data){ window.location.replace(data); },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all, I'm using this colorpicker ( http://www.eyecon.ro/colorpicker ) and am trying to capture
Hey so I installed IR_Black.terminal using the tutorial here: http://blog.toddwerth.com/entries/13 And it's super simple.
I have created an IHttpAsyncHandler that I'm trying to call using AJAX, with jQuery.
Hey. I need some help with jQuery Ajax calls. In javascript I have to
Hey right now I'm using jQuery and I have some global variables to hold
Hey im using JQuery UI (1.8.9) and i have 2 nested resizables like this:
hey, i'm using the Facebook style autoComplete inside a asp.net ajax update panel, by
Hey so I am using Rails PJAX for my web application with twitter bootstrap
Hey I am using the http://th30z.netsons.org/2008/11/objective-c-sqlite-wrapper/ wrapper . My code is this : -
i have a page made AJAX/HTTP Request and the result is JSON formatted .

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.