Last active
December 20, 2020 08:36
-
-
Save rafalrybnik/4b041d1c27c6e0a902d9f3cfff9021c7 to your computer and use it in GitHub Desktop.
Code for article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Survey.StylesManager.applyTheme("modern"); | |
| var surveyJSON = {"pages":[{"name":"page1","elements":[{"type":"rating","name":"rate","title":"On a scale of one to five, how likely are you to recommend my article to a friend or colleague? *","minRateDescription":"(Most unlikely)","maxRateDescription":"(Most likely)"}]}]}; | |
| function sendDataToServer(survey, options) { | |
| //Display information about sending data | |
| options.showDataSaving(); | |
| $.ajax({ | |
| url: 'https://script.google.com/macros/s/AKfycby_XZaWjAb7DMbtXdOsEsPiwS3lM4NkLPhi5f3D1fdhCatn5sOQ0r2v/exec', | |
| type: 'post', | |
| data: JSON.stringify(survey.data), | |
| //We need tell web app that we use plain text. | |
| headers: { | |
| "Content-Type": "text/plain" | |
| }, | |
| processData: false, | |
| complete: function(res, status) { | |
| if (status == 'success') { | |
| //Show that data was send successfully | |
| options.showDataSavingSuccess(); | |
| }else { | |
| //Display retry button in case of error | |
| options.showDataSavingError(); | |
| } | |
| }, | |
| }); | |
| } | |
| var survey = new Survey.Model(surveyJSON); | |
| $("#surveyContainer").Survey({ | |
| model: survey, | |
| onComplete: sendDataToServer | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gist for the article:
How to create online survey for free with SurveyJS and Google Sheets