views:

6811

answers:

2

Hi all, 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.

A: 

what does the formErrorHandling function look like? Is it expecting a selector or a jQuery object?

perhaps what you need is to call it like

formErrorHandling($("#userLastName"));
Victor Jalencas
hi Victor, the formErrorHandling function looks like this: function formErrorHandling(id, filter) { id=id.replace("#",""); ... } afterwards I do a switch(id) and then show the right message error for that id. (and if it has filter, show a specific message)
Adrian
Adrian, If you are removing the "#", why do you bother setting it when you execute the function?
Justin Johnson
Well, you're right, I could just call formErroHandling("userLastName") without #, and not removing it in function. I left it there, for a better tracking of my code. At least, for me, that helps.
Adrian
+3  A: 

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

jitter
jitter, I don't know where the exception occur, interesting fact is that this happens only with one of my form's (I have two forms on my website, both using the same formErrorHandling() function and following the same code pattern) I posted the JS containing this part of form handling here: http://artdevmedia.net/gds/test.js note: the main function wich includes the form related ones is being called after an ajax request success.
Adrian
check expanded answer: especially the part about `$("#"+id)` and `elements:textarea`
jitter
Hi jitter thank you for your time. I tested over and over again and I think that the error might not be caused by my forms or by the error handling function. That's one. Two, it doesn't happen all the time. Anyway, if you have time, take a look here: artdevmedia.net/gds -- here's what I found: If you click on "BUY ALBUM" and then go on with form completing, etc, there's no exception. Now, click on "VIDEO" and then click on X to close video. Sometimes that's the moment when exception throws, other times, the exception throws after closing Video and going back to BUY ALBUM form and submiting it
Adrian
What I mean is that the cause of the exception, after all, is more likely that VIDEO closing link, and I can't seem to know what's wrong with it. Note that the link is created dinamically with js and appended to div. May that be the cause? Am I doing something wrong there? You can look at the hole javascript file if you want and have time. Thanks again for your help.
Adrian
I fixed the bug you mentioned, the one with elements:textarea and rewrote my selectors.
Adrian
Check newly expanded answer
jitter
oh!!! thanks so much jitter, that worked! no more exception! great! :) isn't there a minified version of the new jScrollPane? I can't seem to find it. 43K is quite big. Thanks again for your time and help!
Adrian
Added minified version of it (~8kb). Minified with YUICompressor (the one which jQuery itself uses)
jitter
once again, many thanks jitter!
Adrian