Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uncaught exception: Syntax error, unrecognized expression: #

I get this error on a .click() event in jQuery. I see it in Firebug. I use the latest version, 1.3.2 (min) The click fires an $.ajax() request for a Form in my website. I asked google about this and all he knows is "%" or "[@]" as unrecognized expressions, nothing about the "#".

here is a bit of my code:

    $("form#buyForm #submitForm").live("click", function(e) {
        var errors = 0;

        var inputLastName_value = $("form#buyForm input#userLastName").val();
        if (inputLastName_value == "") {
         errors = 1;
         formErrorHandling("#userLastName");
         return false;
        }
        return false;
    });

This way I check all my inputs for errors, and then call formErrorHandling() who does some show/hide, stuff like that, nothing important.

I read that it might be from a selector of mine, but they all seem to be just fine.

Anybody else had the same problem?

Thanks.

like image 758
Adrian Avatar asked Nov 21 '09 15:11

Adrian


Video Answer


2 Answers

From what I can see the exception seems to be somehow triggered by the jScrollPane plugin you are using.

Try replacing the script you include (v1.2.3 which is as old as from Dec 2008) with a newer version directly from the trunk. Which includes many improvements over v.1.2.3 and fixes the exception for me jScrollPane.js (jScrollPane.min.js minified version of r87 jScrollPane minified with YUICompressor)


removed old answer stuff no longer needed

like image 101
jitter Avatar answered Oct 05 '22 08:10

jitter


In some browsers id might be empty and JQuery chokes on "#" as a selector.

like image 40
Shanimal Avatar answered Oct 05 '22 08:10

Shanimal