Question T2704
Visible to All Users

Retrieve answer for Survey question via api call

created 5 years ago

Hi

I'd like to add a set of questions to a Survey - for example …

Code
api_field_1: api_field_2: api_field_3: api_field_4:

along with a hidden field …

Code
api_request_uuid:

The api_field_* questions above represent data that the user will supply

The Survey will only have one page and in addition to the Submit button should also contain an additional button with the name 'Submit API Request'. When this button is pressed Javascript is called which makes an api request of my backend server (passing it the api_field_* fields).

My backend api uses the information supplied by the front-end to make yet another API request of an external API - when that call returns (with an 'api_request_uuid' result) that information is passed by to the aforementioned initiating Survey Javascript.

Is this possible ? If so how ?

I realize that ideally the ajax request by the Survey would be made asynchronously - but for now its safe to assume that its synchronous.

Thanks
Dave

Show previous comments (2)

    Hello Dave,
    When do you want to have this button?
    Probably this example will help you.
    To be honest, we have discussed your issue with Serge today in the morning and we did not understand your question. Could you please provide more details?

    Thank you,
    Andrew
    SurveyJS Team

      Hi

      The sample was very helpful.

      As far as more details - I'm not sure if I can be more specific than I was in my last comment … I want to be able to add a Button to a question and have control of the JS that runs when that Button is clicked. The sample shows me how to do that.

      Feel free to close this ticket.

      Thanks
      Dave

        Got it.
        Let us know if you need more help on this.

        Thank you,
        Andrew
        SurveyJS Team