0

I'm trying to use http://jqueryui.com/autocomplete/#remote-jsonp within a Codeigniter framework I've looked at http://blog.andrewawhitaker.com/2012/09/29/jqueryui-autocomplete-top-5-sources-of-confusion/

The data source is formatted as a JSON data source with country codes and the place names as a series of objects e.g.

{"success":true,"data":[{"id":"ABZ","name":"Aberdeen","cityId":"ABER","countryId":"UK","city":{"id":"ABER","name":"Aberdeen","cityId":"ABER","countryId":"UK","country":{"id":"UK","name":"United Kingdom","countryId":"UK","isCity":null,"isCountry":true}, "country":{"id":"CH","name":"Switzerland","countryId":"CH","isCity":null,"isCountry":true},"isCity":false,"isCountry":false}]}

The suggestion box displays but the results are undefined because the item parameter of the response is null.

How can I fix this problem? (I tried to paste the jquery code here but the form keeps bitching about my tab indenting).

jquery event:

$("#origin").live('click', function(){

// code in the js fiddle });

jsfiddle: http://jsfiddle.net/bitmapshades/8tmJ5/1/

4

1 回答 1

0

I fixed my own problem in the end by passing function(onResponse){ to avoid duplicating the response reserved keyword, which enabled me to map onResponse.data. Then I had to rewrite the $.ajax call using the $.get method instead.

于 2013-11-14T10:24:14.007 回答