annaWebDev
annaWebDev

Reputation: 3

jQuery error in IE8 - $ undefined

I have looked through answers and I still don't know why I get this error.

Here is the HTML code at the top of my page:

<!DOCTYPE html>
<html lang="en-us">
<head>
    <meta charset="utf-8" />
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <title>MAGI In a Box - Login</title>
    <link href="css/main.css" rel="stylesheet" type="text/css" media="all" />
    <link href="css/grids.css" rel="stylesheet" type="text/css" media="all" />
    <link href="css/misc.css" rel="stylesheet" type="text/css" media="all" />
    <link href="css/tables/demo_table_jui.css" rel="stylesheet" type="text/css" media="all" />
    <link href="css/tables/jquery-ui-1.8.4.custom.css" rel="stylesheet" type="text/css" media="all" />
    <script type="text/javascript" src="js/table_pagination.js"></script>
    <!--Start Style Specific to Project -->
    <link href="css/magi.css" rel="stylesheet" type="text/css" media="all" />
    <!--Start Style Specific to Project -->
    <!-- Add the datepicker stylesheet -->
    <link href="css/datepicker.css" rel="stylesheet" type="text/css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
    <script src="js/jquery-ui.js" type="text/javascript"></script>
    <script>
        function SetFocus() {
            var input = document.getElementById("user_email");
            input.focus();
        }
    </script>
</head>

the jquery is defined before the rest of the script, yet I get these 3 errors:

Message: 'jQuery' is undefined Line: 6Char: 1Code: 0URI: https://demoapp01.smartstream.cognosante.com/MAGIDataEntry/js/jquery-ui.jsMessage: '$' is undefinedLine: 9Char: 1Code: 0URI: https://demoapp01.smartstream.cognosante.com/MAGIDataEntry/js/jQuery.collapsible.jsMessage: Object expectedLine: 3Char: 1Code: 0URI: https://demoapp01.smartstream.cognosante.com/MAGIDataEntry/js/example.js

If the jQuery is declared, why am I still getting these errors?

This is the first time I am posting, I hope I got the formatting correct!

Upvotes: 0

Views: 7280

Answers (2)

Arunkumar
Arunkumar

Reputation: 194

try this one

<script>
   $(document).ready(function(){
   function SetFocus () {
   var input = document.getElementById ("user_email");
    input.focus ();}});
 </script>

import jquery from:

http://jqueryui.com/ [links available here]

Upvotes: 0

Ilia Frenkel
Ilia Frenkel

Reputation: 1977

I noticed from the error that you access your website using https: and you load jQuery using http:. This may cause problems. The best way is to load jQuery like this:

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

Upvotes: 2

Related Questions