Problem with $.get while submitting form
- by bradenkeith
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.