jQuery, Internet Explorer, and another dumb Object Expected Error

Ran into another frustration today and thought I would share.

I have been using jQuery, but needed MooTools also.  Added MooTools, but didn’t realize that my contact form hadn’t been working for a week!  In a panic, I quickly reviewed all the changed I had made in the past week, especially those that would have had any affect on my contact form.  I remembered MooTools.  That was it.  I had to change the namespace for jQuery so MooTools and jQuery wouldn’t fight each other.

I did that by simply adding the following code after my jQuery and MooTools includes:

<script type=”text/javascript”>
var $j = jQuery.noConflict();
</script>
Now, instead of making jQuery calls with just $, I had to use $j.  No big deal.
But now, I noticed another error I was getting that I must not have seen before.  In Internet Explorer, I was getting a wonderful, glorious, object expected error.  I enabled Script Debugger and it pointed me to Character 3 of a jQuery call.
$j(……
In my case, would have been an open parentheses.  What the heck?!
After much searching on Google, I finally ran across a blog that led me to the answer: http://www.scriptingblog.com/javascript-and-ajax/jquery/object-expected-error-in-ie6-ie7-and-ie8/78
I was including my jQuery like this:
<script type=”text/javascript” src=”/jquery.js” />
I changed it to this:
<script type=”text/javascript” src=”/jquery.js”></script>
Refreshed Internet Explorer, made this post, and went to bed.
Hopefully someone else sleeps well tonight now.
Advertisements

8 Comments (+add yours?)

  1. Dimitris Papadopoulos
    Sep 16, 2010 @ 09:17:36

    Wow man, thanks!!!… stupid thing wasted my last 6 hours!!!

  2. ECH didnt work for me....
    Oct 03, 2011 @ 05:11:09

    Ech.. didnt work for me…

  3. Monir Hossain
    Oct 11, 2011 @ 20:20:49

    I’m getting the error on $(document).ready(…

  4. senica
    Oct 12, 2011 @ 13:19:03

    Can you post the exact error? And maybe a little more of your code?

  5. nadeeth
    Jul 09, 2012 @ 09:56:55

    script.type = ‘text/javascript’ ===> replace with ==> script.language = “javascript”;

  6. Anonymous
    Jul 17, 2012 @ 06:59:48

    Thanks nadeeth 🙂

  7. Anonymous
    Oct 16, 2012 @ 19:04:30

    Well. This helped a lot.Realized i had no jquery js file inluded for my jsp files

  8. Sales Calls
    Jan 23, 2013 @ 23:27:28

    Generally I do not read post on blogs, however I would like to say that this write-up very pressured me to try and do so!
    Your writing taste has been amazed me. Thank
    you, very nice article.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: