无法将我的 js 文件链接到我的 pug 浏览器控制台显示
The script from “http://localhost:3000/script.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
2 signin
Loading failed for the <script> with source “http://localhost:3000/script.js”. signin:1:1
我试过用脚本标签来做这件事,但我猜我的 js 代码有一些错误,除非代码在不同的文件中,否则我看不到这些错误。
这是我的哈巴狗文件
script(type='text/javascript' src="http://code.jquery.com/jquery-latest.js")
script( type= 'text/javascript',src="./script.js")
form( id='formSignIn')
div.form-group
label(for='name') Id:
input#name.form-control(type='text', placeholder='id' name='name')
div.form-group
label(for='pw') Password:
input#password.form-control(type='password', name='password')
button.btn.btn-primary(type='submit', id='submit') Sign In
这是我的js文件
$(document).ready(function(){
console.log("hi");
var name,password;
// $("#submit").click(function(){
name= $("#name").val();
password=$("#password").val();
console.log("$$$$$$$$$$$$$", name, password)
$.post("/login", {name: name, password: password} ,function(data){
console.log("AJAx");
});
console.log("@@@@@@@@@@@@@@@@@");
localStorage.setItem('user',name);
}
慕哥6287543
相关分类