JSON - Returning JSON to a input jqGrid autocomplete -


i need in thing: i'm doing autocomplete in jqgrid, , need return json input of autocomplete. i'm doing this, in autocomplete return 1 value , in database have more one. me in this. i'm doing return this:

... header("content-type: application/json"); $i=0; while($row = pg_fetch_array($result)) {    $response->input['value']=$row[ac_fin_g];    $i++; } echo json_encode($response); ... 

but example.. have in database values ac_fin_g: {house, home, cake}. if write letter "o", correct appear "house" , "home" in autocomplete, not happening. when change code above code (for input="ho"):

... header("content-type: application/json"); $i=0; while($row = pg_fetch_array($result)) {    $response->input[$i]['value']=$row[ac_fin_g];    $i++; } echo json_encode($response); ... 

i have correct json:

{"input":[{"value":"home      "},{"value":"house     "}]} 

i'm sorry don't know how fix this. me?


update: @oleg figured out how this. case is:

$i=0; while($row = pg_fetch_array($result)) { $response[] = $row[ac_fin_g]; $i++; } echo json_encode($response); 

:)

ps: link can useful :)

the server should create json data expect jquery ui. corresponds jquery ui autocomplete documentation json data should be

["home", "house"] 

or

[{"label": "home", "value": "home"}, {"label": "house", "value": "house"}] 

instead of

{"input":[{"value":"home      "},{"value":"house     "}]} 

which generate. there way decode other json data on client side, it's better follow jquery ui autocomplete standard format.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -