Object Expected IE8 JS/JQuery issue IE8

internet-explorer, javascript, jquery

Solution

Try placing a semicolon at the end of line 16

from

$('#ddlSt')
.find('option')
.remove()
.end()

$.each(data, function(i,field){

to

$('#ddlSt')
.find('option')
.remove()
.end();

$.each(data, function(i,field){

Problem

This is my first post on here though I browse through SO a lot for answers. I'm running into a problem where IE8 will keep throwing "Object Expected" error. I used IE8's Developer tools and it points to "mymh.js" file ``` <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script> <script type="text/javascript" src="/MyMHome/javascript/mymh.js"></script> ``` mymh.js file only has the following code ``` $(document).ready(function() { $('#hNumber').focus(); $('#ddlDir').change(function () { var selVal = $('#ddlDir').val(); if (selVal == 'N' || selVal == 'S' || selVal == 'E' || selVal == 'W'){ $.getJSON('/MyMHome/DimeServlet?strDir='+$('#ddlDir option:selected').val(), function(data) { $('#ddlSt') .find('option') .remove() .end() $.each(data, function(i,field){ var name = field; $('#ddlSt') .append('<option value= ' + '"' + name + '"' + '>' + name + '</option>'); }); }); $('#ddlSt').focus(); }else{ $('#ddlSt') .find('option') .remove() .end() .append('<OPTION selected value="">Choose a direction first</OPTION>'); } }) .trigger('change'); $('#reset').click(function(){ $('#ddlSt') .find('option') .remove() .end() .append('<OPTION selected value="">Choose a direction first</OPTION>'); $('#hNumber').focus(); }); $('#hNumber').bind('keyup', function() { if($('#hNumber').val().length == 5){ $('#ddlDir').focus(); } }); $('#submitQuery').click(function(){ var houseNumber = $('#hNumber').val(); if(houseNumber.replace(/\s+/g, '').length == 0){ alert('Please enter a house number.'); $('#hNumber').focus(); return false; }else if( (!$.isNumeric(houseNumber)) || houseNumber.indexOf('-') > -1 || houseNumber.indexOf('.') > -1){ alert('Please enter numbers only. You will be prompted later, if the address requires a suffix.'); $('#hNumber').focus(); return false; }else if(houseNumber < 100 || houseNumber > 12999){ alert('Please enter a house number between 100 and 12999'); $('#hNumber').focus(); return false; }else if($('#ddlDir option:selected').val() == 'none'){ alert('Please select a street direction.'); $('#ddlDir').focus(); return false; } }); $('form').keypress(function(e) { if (e.keyCode == '13') { e.preventDefault(); if($('#ddlSt').is(":focus")){ $('#submitQuery').trigger('click'); } else{ return false; } } }); }); ``` The error points to the `<script ... mymh.js></script>` but in the debugger it points to `$document.ready(function() {` Anyone see anything wrong as to why IE8 would keep throwing that error?

Original source