Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 更新烧瓶而不刷新_Javascript_Python_Jquery_Flask_Python Requests - Fatal编程技术网

Javascript 更新烧瓶而不刷新

Javascript 更新烧瓶而不刷新,javascript,python,jquery,flask,python-requests,Javascript,Python,Jquery,Flask,Python Requests,这是我使用ajax连接flask的java脚本,但它显示了404错误。我不明白我哪里出错了 <script> function getBotResponse() { var rawText = $("#textInput").val(); var userHtml = '<p class="userText"><span>' + rawText + '</span></p>'; $("#t

这是我使用ajax连接flask的java脚本,但它显示了404错误。我不明白我哪里出错了

  <script>
    function getBotResponse() {
      var rawText = $("#textInput").val();
      var userHtml = '<p class="userText"><span>' + rawText + '</span></p>';
      $("#textInput").val("");
      $("#chatbox").append(userHtml);
      document.getElementById('userInput').scrollIntoView({block: 'start', behavior: 'smooth'});
      $.ajax({
          type: 'POST',
          url: '/predicton',
          dataType: 'json',
          contentType: 'application/json; charset=utf-8'
            }).done(function(data) {
        var botHtml = '<p class="botText"><span>' + data + '</span></p>';
        $("#chatbox").append(botHtml);
        document.getElementById('userInput').scrollIntoView({block: 'start', behavior: 'smooth'});
      });
    }
    $("#textInput").keypress(function(e) {
        if(e.which == 13) {
            getBotResponse();
        }
    });
    $("#buttonInput").click(function() {
      getBotResponse();
    })

  </script>

您的脚本中存在键入错误:

url: '/predicton'
一定是

url: '/prediction'

(在JS实现中)

您收到的错误或异常是什么实际上我是在迎接404错误,但当我使用时,我得到了正确的结果,但它刷新了页面,我不想纠正并尝试运行该页面,它显示了TypeError:“NoneType”对象没有属性“getitem”
url: '/prediction'