Suggest and Ajax

Hi Webix team,
I want to create a suggest with AJAX like this snipped http://webix.com/snippet/08092794 but it fails with: TypeError t.value is undefined. I want to do the data selection on serverside with parameters. The result data from server are JSON data. Is this the right way or do you have a better idea?
A lot of thanks

Hi,

suggest allows to apply server-side search. Try to set url and dataFeed properties. However, builtin autosuggestions work only with GET requests.

suggest: {
  body: {
     template:"<span class='webix_icon fa-map-marker'></span>" + "#value#",
     url:"mypgm.php", 
     dataFeed:"mypgm.php"
   }
 }

Hi Maria,
a lot of thanks. Is there a plan to support autosuggest and POST requests or autosuggest and DataCollection?

Hi Maria, I’ve done this

webix.ui({
view: “search”,
id: “input”,
value: ‘’,
suggest: {
url:“mypgm.php”,
dataFeed:“mypgm.php”
}
});

the request works and receives following JSON data

{
“items”: [
{
“id”: 1,
“value”: “Mykonos”
},
{
“id”: 2,
“value”: “Mykonos, Greece”
},
{
“id”: 3,
“value”: “Harbour of Mykonos, Greece”
}
]
}

but it fails with: TypeError t.value is undefined.

Hi,

we will add support for “post” proxy in the next update.

Your server-side generates json in an incorrect format. Here is the correct one:

[ 
   { "id": 1, "value": "Mykonos" }, 
   { "id": 2, "value": "Mykonos, Greece" }, 
   { "id": 3, "value": "Harbour of Mykonos, Greece" } 
]

Please check the example (the second text field works with server-side suggestions):

http://docs.webix.com/samples/13_form/01_controls/15_suggest_server.html

Hi Maria, a lot of thanks and a nice weekend