【发布时间】:2017-11-30 01:23:30
【问题描述】:
我正在关注 web.py 框架的教程,我基本上是在为博客设置框架。但是,我在实现注册表单的时候,使用的是网课老师提供给我的一个js文件。如下:
$(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 是否正常工作。谁能帮我找出问题所在?谢谢!
【问题讨论】:
标签: javascript python web.py