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
Post a Comment