Javascript 使用JS文件时Web.py出现问题
我正在学习web.py框架的教程,我基本上是在为博客设置框架。然而,当我实现注册表时,我使用了一个由在线课程的老师提供给我的js文件。具体如下:Javascript 使用JS文件时Web.py出现问题,javascript,python,web.py,Javascript,Python,Web.py,我正在学习web.py框架的教程,我基本上是在为博客设置框架。然而,当我实现注册表时,我使用了一个由在线课程的老师提供给我的js文件。具体如下: $(document).ready(function(){ console.log("loaded"); $.material.init(); $(document).on("submit", "#register-form", function(e){ e.preventDefault(); console.log("form su
$(document).ready(function(){
console.log("loaded");
$.material.init();
$(document).on("submit", "#register-form", function(e){
e.preventDefault();
console.log("form submitted");
var form = $('#register-form').serialize();
$.ajax({
url: '/postregistration'
type: 'POST'
data: form
success: function(response){
console.log(response);
}
});
});
}))
在HTML文件中,我将其定义如下,以及我的其他js文件:
$var js: static/js/jquery-3.2.1.min.js static/js/bootstrap.min.js static/js/material.min.js static/js/ripples.min.js static/js/scripty.js
scripty.js位于static/js中,所以我相信我的语法是正确的,但是当我通过localhost访问网站时,我没有从Chrome中的控制台得到任何反馈。这是一个问题,因为我想使用AJAX来获取信息,但我无法判断js是否正常工作。有人能帮我找出问题所在吗?谢谢
$var js
只定义一个名为js
的参数。它实际上并没有告诉浏览器加载javascript——事实上,它本身并没有告诉浏览器任何事情
您需要在模板中编写适当的HTML:
<script src="/static/js/jquery...."></script>
<script src="/static/js/bootst...."></script>
$if content.get('js', None):
$for x in content.js.split(' '):
<script src="/$x"></script>