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:
A RESTful service's URL. It may include placeholders that allow you to use question values as URL query parameters (see the
reg_countryquestion in this demo).
Specifies which field contains choice values.
Specifies which field contains display texts for choice values.
A path to the array of choices. Specify
pathonly 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.