Problem with $.get while submitting form

Posted by bradenkeith on Stack Overflow See other posts from Stack Overflow or by bradenkeith
Published on 2010-05-05T14:43:54Z Indexed on 2010/05/05 14:48 UTC
Read the original article Hit count: 208

Filed under:
|
|
|

I'm trying to verify that an Account Name is not already in use once a user fills out a form. The code looks like:

    $("#add_account").submit( function () { 
            $.get(
                "'.url::site("ajax/check_account_name").'", 
            {account_name: "t"}, 
            function(data){ 
                alert( data ); 
            }); 
        });

I get a $.get response if the statement sits like this:

    $(document).ready( function () { 
            $.get(
                "'.url::site("ajax/check_account_name").'", 
            {account_name: "t"}, 
            function(data){ 
                alert( data ); 
            }); 
        });

Which leads me to believe that my $.get statement is correct. Is there some jQuery rule I'm not familiar with that would cause this to fail in on submit scenario?

In code block 1, I get values returned like they should. Block 2 gives me a blank response.

Any ideas? Thanks for your time, I know you have better things to be doing.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about get