Question T19912
Visible to All Users

ReferenceError: Survey is not defined

created a year ago

Hello Team,

I am trying to make use of the SurveyJS Form Library integration with HTML/CSS/JS, but I am getting the ReferenceError: Survey is not defined. I can confirm that the link resources (survey-core and survey-js-ui) needed for this to work is correctly loaded (I can see them loaded in the Sources of the page).

The following is the script tag I am using:

HTML
<script> const surveyJson = { elements: [{ name: "FirstName", title: "Enter your first name:", type: "text" }, { name: "LastName", title: "Enter your last name:", type: "text" }] }; try { const survey = new Survey.Model(surveyJson); $(function() { // Render the survey inside the page $("#surveyContainer").Survey({ model: survey }); // Render the survey in a pop-up window $("#surveyContainer").PopupSurvey({ model: survey, isExpanded: true }); }); } catch (e) { console.log(e) } </script>

This is the code from the documentation which I was trying to test but I can't seem to understand why I am getting a ReferenceError. Any suggestion on how to fix this would be appreciated.

Answers approved by surveyjs Support

created a year ago (modified a year ago)

Hello,
Please confirm that you're using jQuery in your application? In this case, you may use the following code to render a survey:

JavaScript
$(function() { $("#surveyContainer").Survey({ model: survey }); });

View Demo for jQuery

Otherwise, please use the survey.render method : View Plunker. A demo for a pop-up survey is available here.

Thanks

    Comments (3)
    T T
    5thDimensionalVader a year ago

      Thank you for your response.

      So, I tested this locally and I was able to get it to work with exactly the same configuration (CDNs resources) as the example. I am trying to make this work with a custom page in Concrete CMS (called Single Pages). I will try the same and post a response if that is successful.

      T T
      5thDimensionalVader a year ago

        Thank you for your help. I have been able to get it working now!

          Hello,
          Thank you for the update. I'm happy to hear that you solved the issue. Please feel free to contact us at any time.