ruby on rails - How to format JSon for Jquery's Autocomplete -


i'm writting autocomplete field using ror , jquery.

when call getjson:

var aeropuertos;     $.getjson('web_services/get_airports', function(data) {         aeropuertos = data;     });      $("#airports_input_origen").autocomplete({source:aeropuertos});     $("#airports_input_destino").autocomplete({source:aeropuertos}); 

i this:

[     [         "(gka)",         "goroka",         "goroka",         "papua new guinea"     ],     [         "(lae)",         "lae",         "papua new guinea",         "00"     ],     [         "(mag)",         "madang",         "madang",         "papua new guinea"     ],     [         "(hgu)",         "mount hagen",         "mount hagen",         "papua new guinea"     ],     [         "(lae)",         "nadzab",         "nadzab",         "papua new guinea"     ] ] 

but seems format isn't right since autocomplete not working , throwing error:

this.source not function

----------------- solved --------------

it json format issue!

instead of sending [ ["", "" , ...] , ... ]

i had send: [ "......." , ".........", ....]

(solution: create json of 1 dimension ruby)

thx anyway time! =)


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -