0

All of the sudden, I'm getting a bunch of warnings in the Firefox Error Console... this wasn't happening earlier today, and I haven't made significant changes. The error is just constantly repeating and accumulating about 3-4 times a second:

Warning: reference to undefined property jQuery.ajaxSettings.traditional

and that points to line 5383 of jQuery.js which is the jQuery JavaScript Library v1.4.2 file that I include. This is the only new code I added today:

$(document).ready(function(){
    // search field focus and blur event handlers
    $('#search-field').focus(function() {
        if($(this).hasClass('placeHolder')){
            $(this).val('');
            $(this).removeClass('placeHolder');
            $(this).addClass('search-field');
        }
    });
    $('#search-field').blur(function() {
        if($(this).val() == '') {
            $(this).val('Search');
            $(this).addClass('placeHolder');
        }
    });
});

So when I put this code in its own file separately... I get the following warnings:

Warning: reference to undefined property E.queue

Warning: anonymous function does not always return a value
   Source File: http://localhost/jQueryChat/js/jQuery.js
   Line: 404, Column: 2
   Source Code:
        }, 

Warning: anonymous function does not always return a value
   Source File: http://localhost/jQueryChat/js/jQuery.js
   Line: 416, Column: 23
   Source Code:
        return jQuery.ready(); 

.. and such. So I don't know why this is happening. Any ideas?

UPDATE: I went to about:config for Firefox and turned javascript.options.strict to false and the warnings went away. But I feel like this is not a solution.

Thanks, Hristo

Hristo
  • 45,559
  • 65
  • 163
  • 230
  • 1
    Remove the code, do you still get the error? – Mark Jun 24 '10 at 17:14
  • 1
    Then that code's not the source of the error, it's somewhere else. Debug with firebug, set breakpoints, etc, find at what line the error is triggered. Or you can remove pieces of your script until the error doesn't doesn't appear anymore and then add them on until you get the error. Anyhow, identify the problem code first. – Mark Jun 24 '10 at 17:19
  • 1
    Here a guy talks about false-positive firefox JS warnings, maybe its one of them? http://www.howtocreate.co.uk/strictJSFirefox.html – THX-1138 Jun 24 '10 at 17:37
  • If you remove the code you have added, does the errors stop showing up? – Rodrigo Gama Jun 24 '10 at 17:16

4 Answers4

1

jQuery gives low importance to warnings, since they are not critic. You can disable strict warnings in FireFox about:config setting javascript.options.strict to false, or live with them in your Error Console.

Anyway, if you disable them, you may still see some warnings when using jquery-ui-1.7.2.custom.css

L84
  • 45,514
  • 58
  • 177
  • 257
German
  • 67
  • 1
  • 3
0

You may also want to restart Firefox and verify the JS bug in another browser, to eliminate any possibility that the JS engine blew up and is giving your erroneous errors.

Robert Hui
  • 744
  • 4
  • 8
  • I restarted Firefox and my computer and I also tried this in Safari. No help restarting, but Safari doesn't show errors. – Hristo Jun 24 '10 at 17:45
0

First of all I can't give comments
Your code works. There's no error.
What you can try to do is to try to override THE $-FUNCTION.

Just try to add to your code
jQuery.noConflict();

And try...

  jQuery(document).ready(function(){
    jQuery('#search-field').focus(function() {
        if(jQuery(this).hasClass('placeHolder')){
            jQuery(this).val('');
            jQuery(this).removeClass('placeHolder');
            jQuery(this).addClass('search-field');
        }
    });
    jQuery('#search-field').blur(function() {
        if(jQuery(this).val() == '') {
            jQuery(this).val('Search');
            jQuery(this).addClass('placeHolder');
        }
    });
});


If you're using any other js framework or plugin. This can help.

Cheers

  • Thanks for your response. I tried your suggestions on just the code I added in a separate independent file... the warnings still show up. – Hristo Jun 24 '10 at 17:51
0

I went to about:config for Firefox and turned javascript.options.strict to false and the warnings went away. But I feel like this is not a solution.

http://www.howtocreate.co.uk/strictJSFirefox.html

Hristo

Hristo
  • 45,559
  • 65
  • 163
  • 230