Search code examples
jqueryfunctioncallback

jquery call back function


i have a form and it validates and submit successfully. all i want is to call back function as "success" when the form has successfully submitted. here is what i have so far but no luck:

$(document).ready(function() {
$("#form1").validate({
        rules: {

                email1: {// compound rule
                        required: true,
                        email: true                 
                }
)};
$('#form1').ajaxForm(function() { 
                alert("Thank you for your comment!"); 
                //document.getElementById("popup").innerHTML = "Thank You!!"
            }); 
    });

here is my form input:

<input name="email1" size="22" type="text"/>

any ideas is greatly appreciated!


thanks for your responses. its not working well for me as i am trying to display "success" in this dhtml fadeout effect: http://dhtmlpopups.webarticles.org/fade-effects.php

i am pretty much stuck going in circles trying to find a way for the alert(success) to print out in the fade out.

any ideas


Solution

  • You're getting an error 'ajaxForm is not a function'? Did you remember to add a script tag referencing the ajaxForm jquery plugin? You need this, AFTER your script tag referencing the main jquery file:

    <script type="text/javascript" src="jquery.form.js"></script>
    

    With src of course pointing to a real file. AjaxForm is not part of the jQuery core.

    If that doesn't work, you could try substituting the $ jquery symbol with 'jQuery' (case sensitive!), to check if $ might be redefined in any of your other scripts.