Using jQuery autosuggest plugin with Geonames

I am relatively new to jquery, and am trying to figure out how to get this autosuggest plugin to work with geonames (returns location info). There is a similar example of it working with the jquery autocomplete here http://jqueryui.com/demos/autocomplete/#remote-jsonp but I can't get it to work with autosuggest. Below is what I'm trying but I get nothing for the results and this browser console error: Uncaught TypeError: Cannot read property 'geonames.adminName1' of undefined.

$("#location2").autoSuggest("http://ws.geonames.org/searchJSON", {selectedItemProp: "geonames.adminName1", searchObjProps: "geonames.adminName1", selectedValuesProp : "geonames.name"});

The json returned from geonames looks like this:

{"totalResultsCount":29,"geonames":[{"countryName":"United States","adminCode1":"UT","fclName":"city, village,...","countryCode":"US","lng":-111.6946475,"fcodeName":"populated place","toponymName":"Orem","fcl":"P","name":"Orem","fcode":"PPL","geonameId":5779334,"lat":40.2968979,"adminName1":"Utah","population":88328},{"countryName":"United States","adminCode1":"UT","fclName":"country, state, region,...","countryCode":"US","lng":-111.69912,"fcodeName":"administrative division","toponymName":"City of Orem","fcl":"A","name":"City of Orem","fcode":"ADMD","geonameId":7174024,"lat":40.2987069,"adminName1":"Utah","population":88328}]}

If I manually copy the JSON into a var called data and then use it for the source like this it works:

$("#location2").autoSuggest("data.geonames", {selectedItemProp: "adminName1", searchObjProps: "adminName1", selectedValuesProp : "name"});

I would also like to know if it would be possible to combine more than 1 value when a result is selected, like adminName1 + name?

Please and thank you!

-------------Problems Reply------------

the remote jsonp response on autocomplete works with the $.ajax() method. Review the documentation on $.ajax().

On success, the ajax method can pass the data to $.map() and then you can do whatever you want with the data (print it out or put it on the DOM)

Category:jquery Views:0 Time:2012-03-15

Related post

  • jQuery AutoSuggest Plugin - preFill options not working 2010-06-23

    I'm using this jQuery AutoSuggest Plugin. It's pretty well documented, but there is a built-in option called preFill that doesn't seem to be working. A few people including myself have had this issue on their support forum. We may just not be enterin

  • Using jQuery autosuggest plugin, how can I generating multiple checkboxes for the cities 2011-10-22

    I'm not really good at Javascript/jQuery yet, so I need some help. I have a jQuery autosuggest plugin on my site, where users can select multiple cities, from my database. What I want now, is to generate a checkbox for every city they selected. So, l

  • Generating checkboxes with the jQuery Autosuggest plugin 2011-10-22

    I'm using the jQuery Autosuggest plugin to select multiple items (cities in this case) and I want to generate a checkbox for each selected city. So far, I've modified the script so, that the name of the city (each city) is wrapped in <span id="cit

  • Need to make an adjust to a jQuery autosuggest plugin 2012-02-21

    I have been looking for jquery autosuggest plugin that fit all my requirements for a while. I have found this one http://discussion.oslund.ca/2011/01/a-simple-jquery-ajax-autosuggest-plugin/ and the demo is http://oslund.ca/demos/ausu/. However. I ne

  • jQuery AutoSuggest Plugin 2010-09-08

    Can somebody post a simple html code on how to implement it,with simple data object. Here is the link http://code.drewwilson.com/entry/autosuggest-jquery-plugin I have tried everything to get it working and i have not succeeded so far, can somebody p

  • Example for Multiple jQuery AutoSuggest plugin on Single Form 2011-02-22

    HI I am using this Jquery Plugin http://code.drewwilson.com/entry/autosuggest-jquery-plugin I have successfully develop this code in my form . but i need this plugin three times in my form(page). I am new in this plugin. Please help me how can i put

  • jQuery autosuggest plugin not displaying results 2011-05-01

    I'm using the plugin by Drew Wilon to search a DB table of city names when the user starts typing to a text field. Via Firebug I can see that data is returned in proper JSON format. So AFAIK everything is working ok on the PHP end. When results are r

  • JQuery autoSuggest Plugin usage with asp.net mvc 2011-09-30

    I've been trying to use this plugin -> http://code.drewwilson.com/entry/autosuggest-jquery-plugin (broken link, see github), but i've been having some problems. Here's what my view looks like. <span> <label for="registrars">Registrar

  • implement multiple instance support on jquery autosuggest plugin 2012-03-30

    Hi below is my code for a jquery auto suggest plugin I am using. I am wondering what changes I would need to make to implement mutiple instance support. (having autosuggest for more than one form on the same page. Thank you. (function($){ $.fn.extend

  • is this a bug in the jquery autosuggest plugin 2011-02-18

    i am using this plugin as an autocomplete suggestion box but one issue is that it allows me to enter the same tag more than once. For example, if you Use the example and type in "m" and choose Mick Jagger and then select that item (which adds it as a

  • jQuery autosuggest only working on one of two fields 2011-06-28

    I'm pretty new to jQuery so please bare with me... I would like to have two textfields with the jquery autosuggest plugin. It is working just fine with the first field: Call: $("#cphContent_txtCity").autocomplete({ source: "ClassLibrary/Cities.aspx",

  • jQuery Autosuggest and PHP/MySQL issue 2011-12-14

    I'm trying to populate an input field, using PHP/MySQL, with the Drew Wilson's jQuery Autosuggest plugin found here: http://tips4php.net/2010/09/ajax-autocomplete-with-jquery-and-php/ I get this error: Warning: mysql_fetch_array(): supplied argument

  • Devbridge jQuery Autosuggest and PHP/MySQL 2011-12-14

    I'm using the Devbridge jQuery Autosuggest plugin and populating it with data from MySQL database using PHP. I have followed this tutorial but it doesn't seem to work. What is wrong? code: $con = mysql_connect("localhost","username","password"); if (

  • jquery autosuggest for multiple words in single textbox 2012-02-25

    how to cofigure the Jquery autosuggest plugin to support for multiple words in a single textbox. Eg. If i want to type "STACK OVERFLOW" in a textbox. as i start typing ST.. It should autosuggest for "STACK" and after space, if i type OV.. It should s

  • jQuery: "Tokenizing" autosuggest plugin allowing the adding of new items 2011-03-17

    I'm looking for a “Facebook style” or “tokenizing” autosuggest plugin for jQuery allowing multiple selections from the suggested list as well as new entries. This plugin does exactly what I need, but it requires Mootools as it seems: http://devthough

  • Facebook style JQuery autocomplete plugin 2009-07-28

    Im after a plugin to do autocomplete like facebook does in that you can select multiple items - similar to how tagging a stackoverflow question works. Here are a couple I ran into: http://wharsojo.wordpress.com/2008/02/18/jquery-facebook-autocomplete

  • Good Jquery Autocomplete plugin consuming JSON 2010-02-12

    I have my customers name in json format i have to use it in a textbox such that it auto completes to give list of users ... Any good Jquery Autocomplete plugin consuming JSON.. I have gone through a similar question of stackoverflow but it didnt help

  • drew's autoSuggest plugin help with AJAX results not showing 2011-01-04

    i use drew's autoSuggest plugin for some time but up until now I have hard coded my data into my JS, I'm trying to see if I can use AJAX to return the JSON data and query data like that. I seem to have it working but no matter what I try I can't get

  • Jquery autosuggest not working 2011-02-02

    Hey guys, I'm using jQuery's autosuggest plugin by using php to get the data. But it doesn't seem to work since I always get: No Results Found, even though I'm sure there are results: Here's the php code: <?php ini_set('display_errors', 'On'); err

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.135 (s). 11 q(s)