Почему этот встроенный опрос не будет работать?

Я следую инструкциям ( https://surveyjs.io/Survey/Builder/), чтобы добавить опрос на мою страницу.

На указанном выше сайте> встроить опрос>

  • Используйте jQuery
  • Для начальной загрузки
  • Показать опрос на странице.

У меня есть приложение laraval, и страница отображает этот исходный код:

<!DOCTYPE html>
    <html lang="en">
    <head>
        <title>The Survey Page </title>

        <!-- Your platform (jquery) scripts. -->
        <link href="https://surveyjs.azureedge.net/1.0.28/survey.css" type="text/css" rel="stylesheet" />
        <script src="https://surveyjs.azureedge.net/1.0.28/survey.jquery.min.js"></script>

    </head>

    <body>
        <div id="surveyContainer"></div>
        <script> alert("This is the survey blade right here right now"); </script>
        <script>
            var surveyJSON = {pages:[{name:"page1",elements:[{type:"paneldynamic",name:"question2",templateElements:[{type:"radiogroup",name:"question3",choices:["item1","item2","item3"]},{type:"text",name:"question4"}]},{type:"paneldynamic",name:"question1"}]}]}

            function sendDataToServer(survey) {
                //send Ajax request to your web server later. Meantime...
                alert("The results are:" + JSON.stringify(survey.data));
            }

            var survey = new Survey.Model(surveyJSON);
            $("#surveyContainer").Survey({
                model: survey,
                onComplete: sendDataToServer
            });
        </script>


    </body>
</html>
  • Итак, я получаю предупреждение и пустую страницу.
  • Внешние ссылки на Scipt правильно отформатированы
  • скрипт - это последнее, что есть на странице (последовательность действий)

В консоли я получаю это:

survey.jquery.min.js:11 Uncaught TypeError: Cannot read property 'fn' of undefined
    at Object.<anonymous> (survey.jquery.min.js:11)
    at t (survey.jquery.min.js:6)
    at survey.jquery.min.js:6
    at survey.jquery.min.js:6
    at survey.jquery.min.js:6
    at survey.jquery.min.js:6
(anonymous) @ survey.jquery.min.js:11
t @ survey.jquery.min.js:6
(anonymous) @ survey.jquery.min.js:6
(anonymous) @ survey.jquery.min.js:6
(anonymous) @ survey.jquery.min.js:6
(anonymous) @ survey.jquery.min.js:6

showSurvey:23 Uncaught ReferenceError: Survey is not defined
    at showSurvey:23

showSurvey мой метод контроллера

public function showSurvey()
    {
        return view ('surveys.survey');   //the laraval blade.. although it's just HTML as per the tutorial example
    }

Что я делаю неправильно?

1 ответ

Пожалуйста, замените следующую строку:

  <!-- Your platform (jquery) scripts. -->

с

  <script src="https://unpkg.com/jquery"></script>
Другие вопросы по тегам