Object Expected Error IE8 JS / JQuery IE8

This is my first post here, although I often look at SO for answers. I ran into a problem when IE8 will ignore the "Object Expected" error. I used the IE8 developer tools and it points to the file "mymh.js"

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

The file mymh.js has only 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 indicates <script ... mymh.js></script>, but in the debugger, it indicates$document.ready(function() {

Does anyone see something wrong regarding why IE8 will ignore this error?

+3
source share
5 answers

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){
+7
source
$(document).ready(function() { });  

This statement may throw an Object Expected error due to the following reasons:

-, javascript (, jquery-1.8.2.min.js) . , . "js" :

<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>  

-, script :

<script type="application/javascript"></script>  

<script type="text/javascript"></script> 
+4

jQuery 2.0.0 IE8. jQuery "jQuery 2.x Internet Explorer 6, 7 8". jQuery 2.0.0 jQuery 1.10.2 .

+4

, , , , , , defer script.

<script type="text/javascript" defer="defer" src="js/libs/jquery-1.8.3.min.js"></script>

<script type="text/javascript" src="js/libs/jquery-1.8.3.min.js"></script>

.

+3

, ​​ IE8-, IE9, IE8.

,

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

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

... , JQuery. ; YMMV.

+3

All Articles