Javascript My jquery.cookie.js报告错误
在我的模板中,我包括了Javascript My jquery.cookie.js报告错误,javascript,jquery,Javascript,Jquery,在我的模板中,我包括了jquery和jquery.cookie.js,但得到了以下错误: 下面是我的html代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>cookie-login1</title> </head> <body> <form action="/cooki
jquery
和jquery.cookie.js
,但得到了以下错误:
下面是我的html代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>cookie-login1</title>
</head>
<body>
<form action="/cookie/login1/" method="post">
<input type="text" name="username">
<input type="text" name="pwd">
<input type="submit" value="add">
<input id="btn" type="button" value="button-add">
</form>
</body>
<script src="/static/js/jquery.cookie.js"></script>
<script src="/static/js/jquery-2.1.4.min.js"></script>
<script>
$(function(){
$("#btn").click(function(){
$.ajax({
url:'/cookie/login1/',
type:"POST",
data:{'username':'root', 'pwd':'123'},
success:function(response){
}
})
})
})
</script>
</html>
cookie-login1
$(函数(){
$(“#btn”)。单击(函数(){
$.ajax({
url:“/cookie/login1/”,
类型:“POST”,
数据:{'username':'root','pwd':'123'},
成功:功能(响应){
}
})
})
})
我的jquery版本是
2.1.4
,我的jquery.cookie.js
版本是1.4.0
html文档解析顺序是从上到下的,您应该首先导入jquery
:
<script src="/static/js/jquery-2.1.4.min.js"></script>
<script src="/static/js/jquery.cookie.js"></script>
<script src="/static/js/jquery-2.1.4.min.js"></script>
<script src="/static/js/jquery.cookie.js"></script>
您必须在
jQuery.cookie.js
之前导入jQuery
jquery.cookie.js需要jquery,但您的编译器现在还不知道它,因为您是在jquery之前加载它的