Load Data from Web Services
SurveyJS Form Library allows you to populate drop-down menus with data loaded from a REST API web service. For this purpose, drop-down form fields include the choicesByUrl
property. It accepts an object with the following properties:
url
: String
A RESTful service's URL. It may include placeholders that allow you to use question values as URL query parameters (see thereg_country
question in this demo).valueName
: String
Specifies which field contains choice values.titleName
: String
Specifies which field contains display texts for choice values.path
: String
A path to the array of choices. Specifypath
only if the array of choices is nested within the object returned by the service. The following path separators are allowed: semicolon (;
), comma (,
).
When you use choicesByUrl
, the form field queries an entire dataset in a single request. This technique may decrease performance on large datasets. In this case, we recommend that you implement lazy loading.