jquery validate 1.8.1 “jQuery” is undefined error IE8

走远了吗. 提交于 2019-12-10 16:32:17

问题


First off - yes - jQuery is being loaded before the validate plugin or any other js files.

Getting 'jQuery' is undefined - jquery.validate-1.8.1.min.js line 13 character 1 in IE8. FF, Chrome & Safari all validate the form perfectly fine.

<title>app title</title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"></script>
<script src="path_to_file/jquery.validate-1.8.1.min.js"></script>
  // CSS and other scripts are here //
</head>
<body>

The above is included from a common header file. I have my actual validate rules on the page itself in a different script block (but I've also tried it in the header file under the jquery and validate script blocks - no dice on IE8.

If I keep plowing through the IE8 debugger, anytime you hit:

$(document).ready(function() {....

IE throws an error to the debugger about "Object expected" and points to '$'


回答1:


Try letting google host the script instead, also it is better to specify the MIME type 'text/javascript' when including the script.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js" type="text/javascript"></script>



回答2:


I found the error - the calls to CDN were http:// and needed to be https://. Even though IE asked if I wanted to load the potentially unsafe content and I said yes, it still never actually loaded the jQuery. Morale of the story - don't believe IE...



来源:https://stackoverflow.com/questions/12323729/jquery-validate-1-8-1-jquery-is-undefined-error-ie8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!