jquery validate 1.8.1 “jQuery” is undefined error

2019-06-27 12:28发布

问题:

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...