Uncaught ReferenceError: jQuery не определено | Триггерный скрипт python с кнопки HTML | Google App Engine - PullRequest
0 голосов
/ 10 апреля 2020

В настоящее время я размещаю веб-сайт в Google App Engine, и пользовательская веб-страница html содержит кнопку, запускающую скрипт python. Моя ошибка заключается в том, что нажатие этой кнопки активирует скрипт python, но на моей странице появляется ошибка Uncaught ReferenceError: jQuery is not defined, а нажатие этой кнопки приводит к Failed to load resource: the server responded with a status of 404 () и ошибке 404 GET:

send    @   jquery-3.4.1.min.js:2
ajax    @   jquery-3.4.1.min.js:2
goPython    @   custom.html:61
onclick @   custom.html:55

![enter image description here][1]][1

Вот мое приложение. js скрипт, откуда исходит ошибка:

(function($){
  $(function(){

    $('.slider').slider();
    $('.carousel').carousel();
    $('.fixed-action-btn').floatingActionButton();
    $('.tooltipped').tooltip();
    $('.materialboxed').materialbox();

    let tooltipInstances;

    window.onload = function() {
      M.FloatingActionButton.init(document.querySelectorAll('.fixed-action-btn'));
      tooltipInstances = M.Tooltip.init(document.querySelectorAll('.tooltipped'));

      // You should remove this event listener when it is no longer needed.
      window.addEventListener('scroll', () => {
        for (let i = 0; i < tooltipInstances.length; ++i) {
          tooltipInstances[i]._positionTooltip();
        }
      });
    }

  }); // end of document ready
})(jQuery); // end of jQuery name space

А вот пользовательская. html страница с кнопкой :

<<!DOCTYPE html>
  <html lang="en" dir="ltr">

  <head>
    <meta charset="utf-8">
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="../static/css/style.css">
  </head>

  <body>
    <script src="../static/js/app.js"></script>

    <!-- Content -->

        <button style="text-align: center; margin-bottom: 150px" class="search-btn" type="button" value=" Run Script " onclick="goPython()">Do Something
          <script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha384-vk5WoKIaW/vJyUAd9n/wmopsmNhiy+L2Z+SBxGYnUkunIxVxAv/UtMOhba/xskxh" crossorigin="anonymous"></script>

          <script>
            function goPython() {
              $.ajax({
                url: "../Python/main.py",
                context: document.body
              }).done(function() {
                alert('finished python script');;
              });
            }
          </script>
        </button>
      </div>
    </div>
  </body>

  </html>

Наконец, при устранении неполадок я удалил <script src="../static/js/app.js"></script> из пользовательского. html (в случае, если это вызывало проблему jquery, которая, похоже, исчезла, но я не уверен, что если это было причиной), но я все еще получаю другие те же ошибки в Chrome инструментах разработчика.

enter image description here

Любой совет и понимание очень приветствуется.

enter image description here

1 Ответ

0 голосов
/ 11 апреля 2020

Попробуйте удалить:

<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha384-vk5WoKIaW/vJyUAd9n/wmopsmNhiy+L2Z+SBxGYnUkunIxVxAv/UtMOhba/xskxh" crossorigin="anonymous"></script>

И добавьте

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
        </head>

Надеюсь, это поможет.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...