views:

54

answers:

4

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

A: 

If you remove the code you have added, does the errors stop showing up?

Rodrigo Gama
this is a comment, not an answer!
jigfox
Just asking beause I seriously think the error has nothing to do with the code you just added... maybe some firefox update?
Rodrigo Gama
yes they do. i tried this before i posted my question
Hristo
i agree... i don't think this is code-related.
Hristo
Sorry, I searched but haven't got the comment link over here...
Rodrigo Gama
you need 50 rep to comment
jigfox
That is strange, I guess... but it's a matter for another thread. Here, I agree with you: The answer was a bad, although it was the only, way I had to comment the question.
Rodrigo Gama
A: 

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
I restarted Firefox and my computer and I also tried this in Safari. No help restarting, but Safari doesn't show errors.
Hristo
A: 

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

Nicolo' Verrini
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
A: 

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

related questions