Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Object expected" error using jQuery only in IE8

I'm getting an error only in IE (v8, I don't know if it happens in older IE versions, but it does not occur in Chrome or Firefox) which brings me the following message when I use IE dev tool's debbuger:

Breaking on JSScript runtime error - Object Expected

Here is my affected code:

$('#deviceProfileSelection').change(function() { //affected line!!!!
// rest of my code...
});

This element #deviceProfileSelection is defined as the following:

<select id="deviceProfileSelection">
   <option value=""><?php echo getSysMessage("dropDownSelect")?></option>
   <!-- and other values...-->
</select>

I've already tried defining the .change listener into a $(document).ready(function () {}); but no success at all. Any other idea?

EDIT

I was trying to include a div using a PHP decision structure, where if a condition was true, it should print a div. But, actually it wasn't printing, I mean, it wasn't printing the opening tag 'div', only the closing tag 'div'.

The browsers could interpret this error, but IE8, and this IE inability was causing the issue.

like image 337
victorf Avatar asked Aug 02 '13 15:08

victorf


1 Answers

The problem is that you haven't added jQuery into your code at all. Add the following inside the <head> tag:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>

That should fix your problem.

like image 98
Joseandro Luiz Avatar answered Sep 24 '22 01:09

Joseandro Luiz