login2.go:34 Uncaught ReferenceError: $ is not defined

前端报错:

login2.go:34 Uncaught ReferenceError: $ is not defined

原因:

1.引入的路径不正确,确保script的src引用路径正确。

在路径前面加上${pageContext.request.contextPath},PageContext类的实例,提供对JSP页面所有对象以及命名空间的访问。${pageContext.request.contextPath}等价于<%=request.getContextPath()%> 意思就是取出部署的应用程序名或者是当前的项目名称。

2.页面jquery.js的引用位置问题,如果导入了其它与jquery有关的js文件,那么jquery.js须在其它js的前面。
 

我这里是没有导入ajax的js

解决方法

添加这句引入js文件即可解决

<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

猜你喜欢

转载自blog.csdn.net/qq_36411874/article/details/93738851